How do I know if I have Windows administrator rights from command line? Particularly on Windows7?
Is there any equivalent to linux id
?
You can run the following script:
NET SESSION >nul 2>&1
IF %ERRORLEVEL% EQU 0 (
ECHO Administrator PRIVILEGES Detected!
) ELSE (
ECHO NOT AN ADMIN!
)
By the way, you can start command prompt with administrative privileges:
cmd
in the search barRelated question answered on stackoverflow:
https://stackoverflow.com/questions/4051883/batch-script-how-to-check-for-admin-rights
Windows Start
button. (I can confirm this works in Win 8.1 and Win 10)
Nov 17, 2017 at 5:47
The problem with this solution is that if UAC is enabled it will just give an access denied error even if you have admin privileges. If you are trying to batch test for admin rights on the machine in general (determine the user is somehow and admin on the machine) then this is useless.
id
does not shows the permissions of a user, it shows theid
. "administrative rights" can be retrieved by (among others)sudo
. then the output ofid
is meaningless in terms of finding out what the user can do. just as a sidenote.