tinyapps.org / docs / Rename Windows user account and profile folder


Scenario:

Steps:

  1. Backup, backup, backup (and know how to restore if things go wrong)

  2. Log in to Windows as Eve (if Fast User Switching is enabled, make sure Alice is logged out completely)

  3. Control Panel\All Control Panel Items\User Accounts > Manage another account > Alice > Change the account name > Bob > Change Name

  4. Rename C:\Users\Alice to C:\Users\Bob

  5. Do a batch search and replace in the registry1 of C:\Users\Alice to C:\Users\Bob with a tool like Advanced Regedit (win32)2,3

  6. Verify no references to C:\Users\Alice remain4 by searching the registry with regedit or reg query
  7. Create a symbolic link5,6 to maintain compatibility with hard-coded references to C:\Users\Alice7:
    C:>mklink /d C:\Users\Alice C:\Users\Bob

  8. Reboot, log in as Bob, and test rigorously, restoring from backup if necessary

Footnotes:

  1. Most guides, including Microsoft's own Renaming a User Account Does Not Automatically Change the Profile Path, only mention updating the value data for ProfileImagePath in the corresponding S-1-5... subkey of HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList:
    ProfileImagePath
    However, there are invariably many more references to the old path which need updating, especially since most guides (including Microsoft's) also fail to include step 6 above (symbolic links).

  2. Or with a batch file or PowerShell script: Registry: find and replace part of a path in a batch file / PowerShell Registry Find and Replace

  3. On a crufty, heavily-used system, removing all occurrences of C:\Users\Alice from the registry required using two additional batch search and replace tools, Registry Toolkit and Registry Replacer.

  4. For longer usernames (e.g., AliceSmith), values containing the short path name (C:\Users\ALICES~1) may also be present and require updating.

  5. Symbolic Links vs. Junctions vs. Hard Links

  6. If you ever decide to delete the symbolic link, be very careful: "If you have a symbolic link that is a directory (made with mklink /d) then using del will delete all of the files in the target directory (the directory that the link points to), rather than just the link. SOLUTION: rmdir on the other hand will only delete the directory link, not what the link points to."

  7. From a comment by GuitarPicker: "[T]here may be some other programs which store the paths elsewhere, such as an .INI file, .XML file or a database."

Sources & more:


last update: 2018.03.22