CMD Master
Back to Blog
UpdatedArnošt Havelka

How to Check Your Windows User and Admin Groups with whoami

Use whoami, whoami /groups, and whoami /priv in CMD to see the account, groups, and privileges a script is actually running with.

Start Interactive Lesson
How to Check Your Windows User and Admin Groups with whoami

If a script behaves differently from an interactive program, first check which Windows identity and privileges it received. whoami reports the effective account; whoami /groups shows group membership; and whoami /priv lists privileges in the current security token. Those results describe the process that runs the command, not a profile you intended to use. Microsoft documents the syntax in whoami.

The whoami lesson provides a browser-safe practice environment. No command here changes your account or grants permission.

Check the effective account

Run:

whoami

The usual output is DOMAIN\\username or COMPUTERNAME\\username. That is the account Windows uses for this process. It may differ from the account shown on a sign-in screen when a scheduled task, service, remote session, or “Run as” action is involved.

Terminal
C:\Users\Student>whoami

Check group membership

To see whether the token includes the local Administrators group:

whoami /groups

Look for BUILTIN\\Administrators. A listed group is not the same as unrestricted access: User Account Control can keep an administrator token filtered until a process is explicitly elevated. Some entries can also be marked deny-only. Read the complete row instead of treating the group name as a guarantee.

Terminal
C:\Users\Student>whoami /groups

Check privileges exposed to the process

Use:

whoami /priv

This lists privileges such as changing the system time or shutting down the computer, along with their state. A privilege that is present but disabled is not currently usable by the process. whoami /priv is a diagnostic report; it does not enable privileges.

Terminal
C:\Users\Student>whoami /priv

Use the result in scripts

Capture the identity before a sensitive operation and record it with the task output. If a command fails with “Access is denied,” compare whoami /groups and whoami /priv in the same window that runs the script. Checking from another terminal can produce a misleading answer because each process has its own token.

Do not use whoami as a password or secret check. It reveals the account context, not credentials. For process ownership and a safe way to stop an unresponsive program, see list and stop Windows processes with tasklist and taskkill.

Knowledge Check

1 / 3

Which command shows the effective account name?

References

These documentation links provide authoritative details for the commands used in this article.

Up Next

Practical: Ver

Scenario: Checking OS compatibility.