To list all user accounts in the Command Prompt (CMD) on Windows, the most straightforward method involves using the net user
command.
Step-by-Step Guide: Listing Users with net user
The net user
command is a fundamental utility in Windows for managing user accounts. It provides a quick overview of all local user accounts present on your system.
Follow these simple steps:
- Open an elevated/administrator command prompt.
- To do this, search for "cmd" in the Windows search bar, right-click on "Command Prompt," and select "Run as administrator." This is crucial because accessing system-level information like user accounts requires elevated privileges.
- Type
net user
and press Enter.- This command specifically requests a list of user accounts managed by the NetBIOS user management system.
- Observe the list of user accounts on your computer.
- The command prompt will display a table-like output, listing all user account names.
Example Output from net user
:
User accounts for \\YOURCOMPUTERNAME
-------------------------------------------------------------------------------
Administrator Guest UserOne
UserTwo DefaultAccount WDAGUtilityAccount
-------------------------------------------------------------------------------
The command completed successfully.
This output provides a clear, concise list of account names.
Understanding User Accounts in CMD
When you use net user
, you're primarily seeing local user accounts configured on your machine. This includes default system accounts created by Windows, such as:
- Administrator: The primary administrative account.
- Guest: An account with limited privileges, often disabled by default for security.
- DefaultAccount: A built-in system account used for specific system processes.
- WDAGUtilityAccount: Related to Windows Defender Application Guard.
Running the command from an elevated command prompt ensures that you have the necessary permissions to query and display all existing user accounts without encountering permission denied errors.
Alternative Commands for Listing Users
While net user
is excellent for a quick overview, other commands offer different perspectives or more detailed information about user accounts.
query user
This command is useful for identifying users who are currently logged on to the system. It provides details like session name, ID, state (active/disconnected), idle time, and logon time.
-
Usage:
query user
-
Example Output:
USERNAME SESSIONNAME ID STATE IDLE TIME LOGON TIME >UserOne console 1 Active none 10/26/2024 10:30 AM
wmic useraccount get name
The Windows Management Instrumentation Command-line (WMIC) tool is powerful for querying system information. This command can list user account names in a more programmatic way, which is often preferred for scripting.
-
Usage:
wmic useraccount get name
-
Example Output:
Name Administrator DefaultAccount Guest UserOne UserTwo WDAGUtilityAccount
You can also retrieve additional properties using wmic
, such as the Account SID or status:
wmic useraccount get name,sid,status
Comparing User Listing Commands
Command | Purpose | Output Type | Requires Admin (for full list) | Notes |
---|---|---|---|---|
net user |
List all local user accounts on the system. | Simple list of names | Yes | Best for a quick, comprehensive overview of local accounts. |
query user |
Show currently logged-on users. | Detailed session info | No (for current user), Yes (for all sessions) | Useful for identifying active sessions and user activity. |
wmic useraccount get name |
Programmatically list user account names. | Columnar list | Yes | Flexible for scripting; can retrieve more attributes (SID , Status , `Description ). |
Practical Tips and Insights
- Viewing User Details: To get more information about a specific user, use
net user [username]
. For instance,net user UserOne
will show details like full name, account active status, last logon, etc. - Disabled Accounts:
net user
will show all accounts, including disabled ones. To check if an account is active or disabled, usenet user [username]
and look for "Account active" status. - Security: While listing users is generally safe, be mindful of sharing this information publicly, as it reveals potential entry points into your system.
- Domain Users: If your computer is part of a domain,
net user
will primarily show local accounts. To list domain users, you might need to usenet user /domain
(if you have the necessary domain administrator permissions) or other specific domain management tools.