Facts
On a non admin Windows account:
Execute in a command prompt: echo %username%
It will display the current user name.
Execute in a command prompt as administrator: echo %username%
It will display the admin user name.
Question
How to get the current user name in a program/script running as administrator ?
A strange behavior:
In a command prompt running as administrator:
explorer %appdata%
will open an explorer window in the AppData of the administrator.start %appdata%
will open an explorer windows in the AppData of the current user.
When you are doing start %appdata% you're opening a new process under a different user – omer727 Oct 06 '15 at 12:46