3
I want to run a batch(.bat) and check if it was opened as an administrator, here’s an example of what I want on linux:
if [ `whoami` == 'root' ] then
echo I am root
else
echo I am not root
fi
I searched but only found these methods:
1 - I don’t want to use this way because the administrator user can use another name.
runas /user:Administrator meubat.bat
2 - Checking the return of this command I can’t pick up anything that I can be sure I am as an administrator
whoami /priv
Running the command (whoami /priv):
Running command(whoami /priv) as administrator:
This command shows the same user name running as administrated or not.
echo %USERDOMAIN%\%USERNAME%
How can I run my script making sure it was run as administered?