In Windows OS, we can find the current logged in username from
windows command line. The logged in user information is stored in
environment variables. So just by printing the value in these
environment variables we can get to know the login name.
To know the login name of the currently logged in user we can run the below command.
There is another command whoami which tells us the domain name also.
source: http://www.windows-commandline.com/current-logged-in-user-name-command/
To know the login name of the currently logged in user we can run the below command.
echo %username%This works on all releases of Windows OS(Windows XP, Server 2003, Windows Vista and Windows 7).
There is another command whoami which tells us the domain name also.
whoamiExample:
c:\>whoami cmdline\administratorBoth of these options to find user name can be useful in batch files to write code in such a way that it works for every user. For example, if your batch file need to access a user specific folder, say Application data, then you can refer the directory as ‘C:\users\%username%\appdata‘.
source: http://www.windows-commandline.com/current-logged-in-user-name-command/
Tidak ada komentar:
Posting Komentar