7

How do I know if I have Windows administrator rights from command line? Particularly on Windows7?

Is there any equivalent to linux id?

1
  • id does not shows the permissions of a user, it shows the id. "administrative rights" can be retrieved by (among others) sudo. then the output of id is meaningless in terms of finding out what the user can do. just as a sidenote.
    – akira
    Sep 14, 2012 at 8:06

2 Answers 2

9

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:

  1. click on windows icon
  2. type cmd in the search bar
  3. press Ctrl + Shift + Enter
  4. press Ctrl+C or click on "yes" when the UAC message appears

Related question answered on stackoverflow:

https://stackoverflow.com/questions/4051883/batch-script-how-to-check-for-admin-rights

2
  • 1
    SHIFT+CONTRL+ENTER doesn't seem to work on win8.
    – Pacerier
    Feb 3, 2015 at 10:41
  • @Pacerier Double check that you're doing from the search feature after clicking the Windows Start button. (I can confirm this works in Win 8.1 and Win 10) Nov 17, 2017 at 5:47
-1

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.

1
  • 2
    This is more of a comment then an actual answer to the author's question.
    – Ramhound
    Mar 14, 2017 at 17:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .