In brief, you need to apply the change the main registry key, then find replace in the registry keys and in your files (it took me 2 hours).
Before starting, create a restore point and backup your registry. Make sure the account you want to modify is an admin account (you can set it as admin running netplwiz in run).
+ First part
This part is well documented here (screenshots)
- right click on
C: User/[old_name] property choose share with nobody (it might take an hour to proceed)
- In control panels create a new admin account with the name
TempAdmin(You will only use it to rename the `C: User/[old_name] folder and modify the registry, then will delete it)
- Logout from your account and login to the
TempAdmin account.
- From TempAdmin rename the
C: User/[old_name] with `C: User/[new_name].
- in the registry key go to
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows
NT\CurrentVersion\ProfileList\ search for the entry that contains
ProfileImagePath and right click/modify and replace the old_name
by the new_name. Close the registry.
+ Edit the user account:
Run (Ctr+run) netplwiz: (it opens user account). Check the checkbox “Users must enter a user name and password to use this computer.” And select the user account’s old_name, and click on the Properties button. Change both the User_name and Full_name with new_name.
+ Try it:
Restart computer, then login in your newly changed account. (If the account with the new name doesn’t show, don't kill yourself. It might be because it’s not set as admin. Just log on in TempAdmin, and the set it as admin using the netplwiz windows.
+ Find and replace the remaining "old_name" in registry.
To find (old_name) replace (new_name) in the registry, you can use regedt33 (open source). Run it as admin. It’s probably better to search with case insensitive, and to run it several times. It will only change the key you own (their ownership is set at your name).
Then use the find feature of the registry to look for the remaining
old_name (regedt33 can't edit protected keys). In the registry find feature uncheck "match the whole string only", press F3 to find again). The quickest way is to change the change the permission AND the ownership of the mother folder, and set it as inheritable for the children*. Then run regedt33 again (this time it will be able to modify the keys) (Edit: regedt33 is buggy, in some computer it will tell you it changed the keys but didn't. I did not find any other (quick) solution than uninstalling and resintalling the software link to these keys, like python)
you will find (some) of the remaining issue in registry using ccleaner
registry tool (right click on the broken key to open it in the
registry)
+ Find and replace the remaining "old_name" in files (mainly your settings).
Run dngrep as admin (open source). Use it to find and replace in C:\Users\[user]\AppData and once with C:\Users\[user]\Desktop . Your search first, then check if the thing should be changed, if so replace it. (You can exclude files using the right click. In option write 1 as the match treshold, to search exactly for old_name)
+ Then fix the other stuff:
Tasks: You will need to export your task in the scheduler, modify
them, and import them again.
check your shortcuts (also in your startup folder)
(*) Edit:
Being an admin isn't enough. You need to have full control (permission), but also the ownership of the key you modify.
To change the permission: right click/permission/ check full control / ok
To change the ownership: right click/permission/ advanced / click on your name. If you want to set the permission for the children, check replace all child permission with inheritable permission from this object.
I also had to disable my antivirus for some difficuly keys, such as HomeGroupStuff. I also had to play with the checkbox "include heritable permission..." and "replace all child object..." for these keys.
The find feature doesn't seem to be reliable. I run it few times (uppercase, lower case, etc.), I still found new old_name to change.