16

Is there anything I can call from the command line which will tell me if the currently logged in user has a limited account or is an admin?

3 Answers 3

16

With the default command tools (no third party downloads) you can use the net command.

%username% will have the username of the current logged on user, so I would use:

net user "%username%"

To display information about the current logged on user. The last section of this shows:

Local Group Memberships      *Administrators       *HelpLibraryUpdaters
                             *HomeUsers
Global Group memberships     *None

Hope this helps

2
  • 1
    Don't forget to add the domain first if your in a domain
    – r0ca
    Commented Sep 23, 2010 at 16:31
  • 1
    If you're on a domain, you can just append the command above with "/DOMAIN". I.e., net user "%USERNAME%" /DOMAIN
    – cowlinator
    Commented Apr 4, 2018 at 20:30
1

You can try this:

net user "%username%" | find /i "*Administrators" >nul 2>&1
if %errorlevel% equ 0 (echo Current user is admin) else (echo Current user is not admin)
-1

What I do most of the time is in the command prompt:

compmgmt.msc /computer=Computer_name

Then, I check in the user/admin groups

You can also check with the PSTools. There is a lot you can do remotely within a domain with this!

2
  • 1
    (1) When I see a question that asks “How can I do X from the command line?”, I usually interpret it as asking for a CLI-only solution — one that could be used in a script (batch file) or remotely (e.g., through psexec). This answer fails in that regard because, while it starts the GUI program from the CLI, it requires the user to use the GUI to get the desired information. (2) Yeah, I guess it’s “obvious” that Computer_name is a placeholder for the name of the computer — except nothing is obvious to everybody. … (Cont’d) Commented Sep 27, 2020 at 8:14
  • 1
    (Cont’d) …  (3) Are you suggesting that this command can be used remotely?  Then you should describe how to identify the “currently logged in user” (as required by the question).  (4) Are you suggesting that this command should be used locally? (4a) How is the user supposed to learn the name of the computer he’s on? (4b) Why specify /computer= at all?  Just leave it off, and it will attach to the local machine. (Or are there situations where it won’t?) (4c) The OP still has to find out the name of the currently logged in user. Commented Sep 27, 2020 at 8:14

You must log in to answer this question.

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