Wednesday, November 24, 2010

Delete Windows User Profile

The users hive is located under their user directory (NTUSER.DAT) so deleting the directory with an rmdir /s /q {username} should suffice. The only part that wouldn't be deleted is under the profile list in the registry HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\ProfileList but all that does is map the SID to a profile location.
If the user logs in and the directory doesn't exist, it'll be created again.
Unfortunately, without having them elevate themselves as admins, they won't be able to delete user profiles.
Batch file:
set /p USERTODEL=Enter the username to delete: set USERTODEL=C:\Users\%USERTODEL%
if exist "%USERTODEL%" rmdir /s /q %USERTODEL%
  
 
To clear user local profile via registry :
  1. Press on Start > Run >Regedit
  2. Navigate to the following registry key :“HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList”
  3. Under ProfileList navigate to  binary key’s like this :S-1-5-21-3656904587-1668747452-4095529-500
  4. On the right side under  ProfileImagePath you’’ll see the username and profile path.
  5. Chose the one with the desired user and delete the long reg key like :“HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList”

No comments:

Mimmo97 Blog Archive