Re: Win32Lib getUserName() problem

new topic     » goto parent     » topic index » view thread      » older message » newer message
AndyDrummond said...
jimcbrown said...
AndyDrummond said...

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.

AndyDrummond said...

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.)

AndyDrummond said...

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.

In WinXP, if I create a new user, called FRED for the sake of argument, then a new folder C:\Documents and Settings\FRED is created, which contains all the odds and ends like Desktop, My Documents and so on. If I then go into Control Panel and Users, I can change the user's name to, lets say, GEORGE, this does not rename the folder C:\Documents and Settings\FRED, it leaves it alone. But if I try and log on, I get offered the new name GEORGE, and indeed this appears in almost all places where the user name is required. But nevertheless the folder where all the user's stuff is kept is still called FRED. This is all true. However, the environment still shows the username to be FRED.

My own user was created using the name Andrew, and that is still there. But I log on as Andy Drummond, log off as Andy Drummond etc. But the name Andy Drummond does not appear anywhere in the environment variables. In there, USERNAME=Andy Drummond.

Let's not chase this any further; I don't want to waste anyone's valuable time, and I certainly don't want to sound acrimonious. There are many more ways to skin a cat, and I now simply ask the user to enter his name and save it in an INI file for subsequent use. Seems OK.

Thank you all for your help. Back to useful stuff like Eu4 debugging...

Andy

Your postings appear to contradict themselves (and the latest post seems to contradict itself), which is very confusing. Additionally, I admit that I did not know that XP's usernames were allowed to contain spaces.

Although this won't help you, I'd still appreciate it if a W32 guru could explain how usernames in XP are suppose to work.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu