Microsoft has actually documented a very simple and clean way to rename a user profile folder.
EDIT Feb 2022: If you plan to use winget to manage your Windows installations at any point, note that Microsoft now warns against using this procedure under Windows 10 or later as it can stop winget working. Information about winget
There is no need to create a new user account, so all the settings associated with the existing user profile are preserved. And the only registry change required is to edit a single string value (the one that tells Windows the path of the user profile folder):
- Log in by using another administrative account.
Note. You may need to create a new Administrative account at first.
- Go to the C:\users\ folder and rename the subfolder with the original user name to the new user name.
- Go to the registry and modify the registry value ProfileImagePath to the new path name.
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\<User SID>\
The procedure quoted above was provided by Microsoft (here) in relation to a perceived issue with Windows 7, and continues to work in Windows 10.
The ProfileList registry key contains a number of sub-keys. To find out which one to change, click on each sub-key and examine the values, to find the sub-key with the right ProfileImagePath:
For example, let's say we want to get rid of the space in a user profile folder name. So in step 2, we use File Explorer to navigate to
C:\Users and rename the
John Smith subfolder
JohnSmith. And in step 3, we click on the
<User SID> sub-keys until we find the one with ProfileImagePath
C:\Users\John Smith, and change it to
You may find you have to restart instead of just logging out and logging back in. Otherwise, when you try to rename the folder, Windows may report that it is being used by another program.
Environment variables (info)
Some applications create env vars with the user profile path fully expanded, so it's advisable to check for these and reboot if any needed fixing.