How to determine logged on user in Windows XP from the command line
Getting logged on users from the command line
While user accounts can typically be managed through a GUI there are times when user account management via the command line may be preferred.
For instance, today I encountered an issue where a user was logging on and having some access permissions to their files. It turns out their original user profile had become corrupted and Windows was logging them as a temporary user. The GUI showed them logged in normal but the command line said otherwise!
Modern OS’s such as Windows Vista, Windows 7, and Windows 8 permit the use of the ‘whoami’ (without the quotes) command. XP and older operating systems do not.
To determine the current logged on user from an XP command line open a command prompt:
Start -> Run -> cmd -> Press Enter Or Windows Key + R
echo %username% (with the percentage symbols)
You can also determine current domain:
You can also combine them into one command:
echo %username% %userdomain%
These commands also work in Windows Vista, Windows 7, and Windows 8 but it’s a lot easier just to type ‘whoami’.
(As a side note it is possible to get the ‘whoami’ function working in XP as well. Installing the Windows XP Service Pack 2 Support Tools adds this functionality. Once installed ‘whoami’ will work!)
If all else fails you can always run ‘net user’ to determine what user accounts are available on the PC and troubleshoot from there.