Re: Win32Lib getUserName() problem
- Posted by jimcbrown (admin) Dec 18, 2009
- 1227 views
The environment variable USERNAME is essentially the name of the folder below "C:\Documents and Settings", which is not changed when you go into Control Panel & Users and so on to change your name. That name is used when you are logging in, and is presumably held in a config file of some kind by Windows.
This is the username.
Maybe I could search for such a file with the new name in to see where it is, but the Windows search algorithm seems to lack something fundamental. Logging off and on has no effect; because so many programs remember paths, Windows doesn't change its own internal pathname & user name, just stores a copy someplace for display purposes.
There should not be anything internal regarding this. Once the appropriate registry entries are located, it should be possible to manually change all of this in concert, I should think. (Not saying it's a good idea, mind you.)
I dare say *nix must do something similar because once a working environment is set up, you don't want to start changng the almost-root folder name or you'd foul most programs up.
I'm not aware of a command that simply renames a user, but it's possible to do this maually. In most cases, one would rename the user's directory to match the new username as well, but it's possible to keep the old directory's name if that is necessary.
The full path of the user's home directory is set up in /etc/passwd
The user's Full Name is also in /etc/passwd in the GECOS field. Both these variables can be edited with the adduser or usermod commands.