Commenter Steven asked in response to my article on how not to delete local user profiles for the correct way to script the deletion of user profiles. Here is how. For completeness sake I start with the manual method.
Deleting Profiles Manually
- Open the control panel applet „System Properties“ and navigate to the tab „Advanced“. I know of the following shortcuts for this often needed dialog box:
- Press Win+Break
- Press Win+R to open the run dialog box. Type in control sysdm.cpl,,3and press enter. Note there must not be entered a space in front of the commas.
- Click on the settings button in the user profiles section.
- In the dialog that appears, choose the appropriate user profile and click on delete. Note: you must be an administrator for the delete button to even show up. And: you cannot delete your own profile.
Deleting Profiles Automatically
Microsoft’s delprof utility can be used to delete all local(ly cached) user profiles. Optionally, only profiles not used for a specified number of days are deleted. Another option (/r) restricts the deletion to locally cached roaming profiles.
Please note: By default, delprof deletes all profiles! It does, however, ask for confirmation before each delete, unless the parameter /q is specified.
Delete all cached copies of roaming profiles on the local machine:
delprof /q /i /r
Delete all profiles not used for 10 days on computer server:
delprof /q /i /c:\\server /d:10
Microsoft’s Delprof does not work on operating systems newer than Windows XP/2003. It is not compatible with Windows 7 and 2008 R2. To fill the void I have written a syntax-compatible successor called Delprof2 which works on all versions of Windows and is even more powerful. Find more information and download Delprof2 here.