Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Having an issue with deleting user profiles on server 2008 when they become corrupt, we have successfully done this now by closing a process but it killed the server and forced a restart, not to bad as we are testing this server and only had 2 users on.

Is there any safe/quick way to do this via a script ?

share|improve this question
the profile is being held open most likely by the client, uphclean (client side) can be used to close this connection automatically. When a users logs out it doesn't disconnect from the profile for a while otherwise. – tony roth Aug 8 '12 at 15:29
Is this server a VMware VM by any chance? – joeqwerty Aug 9 '12 at 4:05
Hi Joe, yes its hosted on vmware. – JJJJNR Aug 9 '12 at 12:29
up vote 0 down vote accepted

ntuser.dat is a registry hive file that contains the registry entries associated with the profile. The kernel itself has the file open; the hive has to unloaded to unlock the file. You can force it to unload with reg unload, though you'll need the SID of the user that owns the profile. There is a related "classes" hive that expands HKEY_CLASSES_ROOT for each profile as well.

reg unload HKEY_USERS\S-1-5-21-1555713158-3015222722-1959872020-2924
reg unload HKEY_USERS\S-1-5-21-1555713158-3015222722-1959872020-2924_Classes

This applies to all versions of Windows since XP and there is something similar in all the previous versions of WinNT as well.

In general, it would be better to let Windows unload the profile itself, by removing the open references to it.

share|improve this answer
prior to win7 the process to clean these issues up was a download by ms called uphclean – tony roth Aug 8 '12 at 16:30

You can do this in Powershell:

get-wmiobject win32_userprofile -filter "localpath='c:\\users\\BadProfile'" -computer MyServer | remove-wmiobject

That should do it for you. Obviously, replace "BadProfile" with the user's username and MyServer with the name of your server. The -computer switch lets you do it remotely if necessary. You can omit that switch if you're working with a local profile.

share|improve this answer
won't work if the profile is being held open, which in this case is more then likely. – tony roth Aug 8 '12 at 15:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.