The environment variable
USERNAME is defined in the registry key
Note however that as the keyname implies, the variables in this key are volatile, meaning that while the user can change them, they will not retain their new values and will be overwritten by the system with derived values (sort of like registry RAM). The
username environment variable is one of the few variables that cannot be set, or even if they are, they will not “stick”, just like how setting a variable in a console session is lost when you open a new one.
It should update the variable with the new user name. Have you tried logging out and back in or rebooting the system?
Where/how did you change the user name, the User Accounts Control Panel applet? The User Accounts applet only changes the user’s name, not the actual username. Use
lusrmgr.msc to modify the user name by clicking it, pressing F2 and changing it (then log out/in or reboot).
If that does not work, then search the registry for the old/original user name and change it there(s?). Check the following keys: