Deleting a Local User Profile - Not as easy as one Might Assume

In many environments it is a common practice to delete user profiles prior to conducting tests in order to start with a clean slate. However, this may prove more difficult than anticipated.

Most people think that a local user profile only consists of the directory %USERPROFILE% typically located below C:\Users on Vista and Server 2008 (and newer). But there is more. Windows keeps track of the local profile incarnations in the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList. For each locally stored profile a subkey is created whose name is set to the profile owner’s SID. Here is the content of a sample ProfileList subkey:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\S-1-5-21-1659004503-1788223648-1417001333-500]
"ProfileImagePath"="%SystemDrive%\Documents and Settings\Administrator"
"Sid"=hex:01,05,00,00,00,00,00,05,15,00,00,00,57,66,e2,62,a0,20,96,6a,75,b9,75,54,f4,01,00,00
"Flags"=dword:00000000
"State"=dword:00000100
"CentralProfile"=""
"ProfileLoadTimeLow"=dword:224c9af0
"ProfileLoadTimeHigh"=dword:01c92f98
"RefCount"=dword:00000000
"RunLogonScriptSync"=dword:00000000
"OptimizedLogonStatus"=dword:0000000b

How Not to Delete a Profile

Now, what happens if you simply delete the user profile directory below C:\Users without modifying the registry? The next time the user logs on Windows displays a balloon tip whining that Windows could not load the user profile and that the user was logged on with a temporary profile. Is that bad? Yes! Temporary profiles are a last resort if Windows cannot load the user profile. Upon logoff they are deleted and all data is lost. That certainly is a reason to avoid them.

The Right Way

If you need to delete a profile, either

  • make sure to delete the profile directory and the associated ProfileList subkey, or
  • open the control panel applet “System Properties” by running sysdm.cpl and delete the profile from there.

What if I Already Deleted a Profile the “Wrong” Way?

If Windows finds a ProfileList subkey matching your SID without an associated profile directory it backs up the ProfileList subkey. Prior to creating the temporary profile the ProfileList subkey is renamed to SID.bak. About the reason for that strange behavior I can only speculate. Maybe someone thought this would facilitate restoring the original state from a backup.

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.

What About XP and Server 2003?

The behavior described in this article applies to Vista, Windows 7 and Server 2008 (including R2). Their predecessors XP and Server 2003 use a more simplistic approach. If a ProfileList registry subkey exists but the corresponding directory is not accessible, they simply create a new local profile and overwrite the data in the ProfileList key. Not even an event is logged to the Windows event log. This behavior is certainly simpler but at the same time much more realistic. Not every change is for the better…

References

MS KB: A temporary profile is loaded after you log on to a Windows Vista-based system
MS KB: A temporary user profile is created every time that you log on to a Windows Vista-based computer that is connected to a domain

Comments

Related Posts

New OS = New Profile = User State Lost. True or False?

New OS = New Profile = User State Lost. True or False?
Going to Windows 7 or Server 2008 (R2) means trouble. Let me use an analogy to explain why. You are in charge of moving people from their old houses to shiny new buildings. You have planned everything perfectly. The new homes are beautiful and located in a great neighborhood. But still, after moving house, people start to complain. They do not feel at home. You forgot to take all those seemingly unimportant things that make a house a home: pictures, plants, all sorts of personal stuff. Impossible, you say? People would never leave their personal belongings behind? I agree: when it comes to moving house, not taking at least most of the personal stuff is highly unlikely. But in IT it is common practice.
User Profiles

Latest Posts

Fast & Silent 5 Watt PC: Minimizing Idle Power Usage

Fast & Silent 5 Watt PC: Minimizing Idle Power Usage
This micro-series explains how to turn the Lenovo ThinkCentre M90t Gen 6 into a smart workstation that consumes only 5 Watts when idle but reaches top Cinebench scores while staying almost imperceptibly silent. In the first post, I showed how to silence the machine by replacing and adding to Lenovo’s CPU cooler. In this second post, I’m listing the exact configuration that achieves the lofty goal of combining minimal idle power consumption with top Cinebench scores.
Hardware