I want to run a batch (.bat) and check if it was opened as an administrator, here is an example of what I want in 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 do not want to use this way because the admin user can use another name.
runas /user:Administrator meubat.bat
2 - Checking the return of this command I can not get anything that can make sure I'm an administrator
whoami /priv
Running the command (whoami / priv):
Runningthe(whoami/priv)commandasanadmin:
This command shows the same user name running as managed or not.
echo %USERDOMAIN%\%USERNAME%
How can I run my script making sure it was run as managed?