Tuesday, February 01, 2005

Windows XP: Change user name in "Documents and Settings"

Windows XP: Change user name in "Documents and Settings": "the names under "Documents and settings" do NOT necessarily have to be the same as the user's name. The profile folders get created when a user logs on for the first time. This is the first possibility for a profile folder name to be different from the user's name.
Say you have a local account "Administrator", and you have logged on with it already. You join the machine to a domain, and logon with the *domain* account "Administrator". The domain account will (probably) create a profile folder named something like Administrator.domainname.
The second possibility: Renaming a user.
Let's stay with the above example and say that, for "security" reasons, the local Administrator's name was changed to "LocalAdmin", and a local dummy user "Administrator" was created. The LocalAdmin account will *still* use the profile folder "Administrator", and the dummy "Administrator" will get a profile folder with a name like "Administrator.001".
The profile folders are bound to the user's SID, not the user's name. The SID doesn't change when renaming a user name.

usually, there is absolutely no need to change a profile folder's name. If you want to know which user name actually uses which profile folder, you can logon with the user and check the environment variable %UserProfile% (do *NOT*, never, ever, use "C:\documents and settings\%username%" when accessing a profile, for example in a script).
The other possibility is a bit more complicated. Get PsGetSid from Sysinternals (, then use that to retrieve the user's SID. Open regedit, go to HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList, check the SIDs listed there against the SID you're looking for, and then look at the value of "ProfileImagePath" (most of them will actually reflect the user's name, but as I said before, don't rely on that).
Now, to rename the folder while making sure that the user can still access the profile, do the following:
* Retrieve the user's SID.
* Logon with an administrator account (other than the user whose folder you want to change).
* Rename the folder to the user's current name (or whatever you want to name it).
* Open regedit, go to HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\, and change the "ProfileImagePath" to the new location.

How to Move the Location of a Locally Cached Profile"

No comments: