0

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 ?

3
  • 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
    Commented Aug 8, 2012 at 15:29
  • Is this server a VMware VM by any chance?
    – joeqwerty
    Commented Aug 9, 2012 at 4:05
  • Hi Joe, yes its hosted on vmware.
    – JJJJNR
    Commented Aug 9, 2012 at 12:29

2 Answers 2

0

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.

1
  • prior to win7 the process to clean these issues up was a download by ms called uphclean
    – tony roth
    Commented Aug 8, 2012 at 16:30
0

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.

1
  • won't work if the profile is being held open, which in this case is more then likely.
    – tony roth
    Commented Aug 8, 2012 at 15:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .