d] whoami command – Show current user name.
You can use the username variable: %USERNAME%
Username:
echo %USERNAME%
Domainname:
echo %USERDOMAIN%
You can get a complete list of environment variables by running the command set
from the command prompt.
Just use this command in command prompt
C:\> whoami
It should be in %USERNAME%
. Obviously this can be easily spoofed, so don't rely on it for security.
Useful tip: type set
in a command prompt will list all environment variables.
%USERNAME%
is the correct answer in batch and other in Windows environments.
Another option is to use %USERPROFILE%
to get the user's path, like C:\Users\username
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With