Deleting User Profiles – Correctly

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

  1. 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+R to open the run dialog box. Type SystemPropertiesAdvanced.exe
    • Press Win+R to open the run dialog box. Type control sysdm.cpl,,3 and press enter. Note there must not be entered a space in front of the commas.
    • Press Win+Break
  2. Click on the settings button in the user profiles section.
  3. 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.

Usage examples:

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.


MS KB: How To Delete User Profiles by Using the User Profile Deletion Utility (Delprof.exe) in Windows 2000

8 Responses to Deleting User Profiles – Correctly

  1. Udo R. Jetschmanegg December 4, 2008 at 12:32 #


    I’ve got a profile with status “temprorary” in the sysdm-windows and want to delete it, so that the user gets his “normal” profile back which is stored on a share. With delprof the profile isn’t listed, so who would I delete this file correctly?

    When I log in with this user, the profile is loaded into c:\documents and settings\temp…


  2. Udo R. Jetschmanegg December 4, 2008 at 12:54 #

    Solved – I’ve deleted the reg-structure in HKEY_Users for this user, so I could delete the TEMP-profile in C:\documents and settings. After a re-login the old profile was used.


  3. Helge Klein December 4, 2008 at 12:55 #

    From an earlier post:

    “Whatever the reason, once you got a temporary profile the SID.bak key lingers in the registry. It needs to be deleted to get back to normal profile behavior.” (Applies to Vista/2008)

  4. Helge Klein December 4, 2008 at 12:57 #

    Good to hear the problem is solved ;-)

  5. Joe Shonk December 9, 2008 at 23:20 #

    On my site, I do have a better version of DelProf.exe and it is script based to it easy modify.


    Also note: Users should be running UPHClean… DO NOT DELETE a profile that is LOAD or has handles associated to it.

  6. Helge Klein December 10, 2008 at 13:52 #


    your script looks impressive! Thanks for pointing me to it.

  7. Naim cote June 16, 2009 at 23:00 #

    Hi Klein, I regularly read you Blog and I can finally contribute something.

    Just a little note, we had been using DelProf.exe on Windows 2008 servers and Vista machines. We are setup with Roaming Profiles and folder Redirection, Delprof gets ride of the user profile in the registry and c:\users but it fails to remove any cached data used by the offline files (Stored in c: Windows\CSC)

    The result would be that after removing a profile with Delprof and logging back on with the roaming profile, the Redirected Folders would fail to find the correct network path, using the local cached data in c:\Windows\CSC and at this point the only solution was to add the following registry entry Reg \\%TargetCmp%\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Csc\Parameters /v FormatDatabase /d1 /t REG_DWORD /f in order to flush the Off Line cache at Reboot.

    After searching for a while I found that in Vista/2008 the only “correct” way to delete profiles by script is the use the WMI Win32_UserProfile. class

    For example we now use the following script the delete roaming profiles remotely :

    TITLE %~nx0
    @Echo on

    @echo .
    Set /p TargetCmp=Enter computername on which we will delete all the roaming profiles:

    for /f “tokens=1,2″ %%a in (‘wmic /node:”%TargetCmp%” path win32_UserProfile get RoamingConfigured^,Sid^|find “TRUE”‘) do (
    echo %%a echo %%b
    wmic /node:”%TargetCmp%” path win32_UserProfile where Sid=”%%b” Delete


    • Helge Klein June 17, 2009 at 09:04 #

      Indeed, the client-side cache (CSC) also needs to be cleaned up.
      Thanks for contributing the script!

Leave a Reply