what to know
- Enter the net user command in the command prompt to get a list of all local user accounts.
- The net user command can add, delete, and change user accounts on the computer.
- Some switches using this command include username , password , /add , and /delete .
This article describes how to use the net user command in Windows. This page contains various net user switches as well as some examples of net user commands that you can adapt to your own commands.
Network user [ username [ password | * ] [ /add ] [ options ]] [ /domain ]] [ username [ /delete ] [ /domain ]] [ /help ] [ /? ]
If you are not sure how to read the network user command syntax explained above or in the table below, see How to read command syntax. The availability of certain network user command switches and other network user command syntax may vary depending on the operating system.
Network user command options | |
---|---|
Options | explain |
Internet users | The net user command alone displays a very simple list of every user account (active or not) on the computer you are currently using. |
username | This is the name of the user account you want to change, add, or delete, up to 20 characters in length. Using the username without other options will display detailed information about the user in the command prompt window. |
password | Use the password option to modify an existing password or specify a password when creating a new username . You can use the net account command to view the minimum required characters. A maximum of 127 characters is allowed1 . |
* | You can also choose to use * instead of password to force the password to be entered in the command prompt window after executing the net user command. |
/Add to | Use the /add option to add a new username on the system. |
Options | See Additional Net User command options below for a complete list of available options to use when executing net user. |
/field | This switch forces network users to execute on the current domain controller instead of the local computer. |
/delete | The /delete switch deletes the specified username from the system. |
/help | Use this switch to display detailed information about the net user command. Using this option is the same as using the net help command with net user: net help user . |
/? | The standard help command switches can also be used with the net user command, but only basic command syntax is shown. Executing net user without options is equivalent to using the /? switch. |
[1] Windows 98 and Windows 95 only support passwords up to 14 characters long. If you are creating an account that is likely to be used on a computer with one of these versions of Windows, consider keeping the password length within the requirements of those operating systems.
Where options are noted in the net user command syntax above, the following options are used:
Additional network user command options | |
---|---|
Options | explain |
/Activity: { yes | no } | Use this switch to activate or deactivate a specified user account . If you do not use the /active option, network users will assume yes . |
/comment: " text " | Use this option to enter a description of the account. A maximum of 48 characters is allowed. Text entered using the /comment switch can be viewed in the Description field of the user profile in Windows Users and Groups. |
/Country code: nnn | This switch sets the country code for the user, which determines the language used for error and help messages. If the /countrycode switch is not used, the computer's default country code is used: 000 . |
/expires: { date | never } | The /expires switch is used to set a specific date when the account (but not the password) expires (see below). If the /expires switch is not used, never is assumed. |
Date ( /expires only) | If you choose to specify a date , it must be in mm / dd / yy or mm / dd / yyyy format, with the month and day as numbers, fully spelled out or abbreviated to three letters. |
/Full name: " name " | Use the /fullname switch to specify the real name of the person using the username account. |
/homedir: path name | If you want a home directory other than the default 2 , use the /homedir switch to set the pathname . |
/passwordchg: { yes | no } | This option specifies whether this user can change his or her own password. If /passwordchg is not used, network users assume yes . |
/passwordreq: { yes | no } | This option specifies whether this user requires a password. If this switch is not used, "yes" is assumed. |
/logonpasswordchg: { yes | no } | This switch forces users to change their password the next time they log in. If you do not use this option, network users will assume "no" . The /logonpasswordchg switch is not available in Windows XP. |
/config file path: pathname | This option sets the pathname of the user's login profile. |
/script-path: pathname | This option sets the pathname of the user's login script. |
/Times: [ Time Range | All ] | Use this switch to specify the time range during which users can log in (see below). If you don't use /times , network users will assume that all times are OK. If you do use this switch but do not specify timeframe or all , net user will assume that no time is available and the user will not be allowed to log in. |
Time range (only /times ) | If you choose to specify a time range, you must do it in a specific way. The days of the week must be spelled out completely or abbreviated in MTWThFSaSu format. The time of day can be in a 24-hour format or a 12-hour format using AM and PM or AM and PM . Time periods should be separated by dashes, dates and times should be separated by commas, and date/time groups should be separated by semicolons. |
/user comment: " text " | This switch adds or changes user comments for the specified account. |
/workstations: { computer name [ , ...] | * } | Use this option to specify the host names of up to eight computers that the user is allowed to log on to. This switch is really only useful when used with /domain . If you do not use /workstations to specify allowed computers, all computers ( * ) are assumed. |
After you run the net user command using the redirection operator, you can store the output of whatever appears on the screen. For instructions, see How to Redirect Command Output to a File.
[2] In Windows 11, Windows 10, Windows 8, Windows 7, and Windows Vista, the default home directory is C:Users[username]. In Windows XP, the default home directory is C:Documents and Settings[username]. For example, if the user account on a Windows 11 tablet is named "Tim," the default home directory created when the account is first set up is C:UsersTim.
Here are a few ways to use this command.
The first example of the net user command shows that, in its simplest form (typing net user ), it will produce a list of all users on the computer, as shown below:
Administrator DefaultAccount Extra
Guest jonfi WDAGUtilityAccount
This computer has more than ten user accounts, so they are divided into columns.
You can also use net users instead of net user . They are completely interchangeable.
net user administrator
In the net user example above, the command generates all the details of the administrator user account. The following is an example of what might be displayed:
User name Administrator
Full Name
Comment Built-in account for administering the computer/domain
User's comment
Country/region code 000 (System Default)
Account active No
Account expires Never
Password last set 8/24/2020 1:21:25 PM
Password expires Never
Password changeable 8/24/2020 1:21:25 PM
Password required Yes
User may change password Yes
Workstations allowed All
Logon script
User profile
fileHome Home directory
Last logon 11/9/2021 11:48:13 AM
Logon hours allowed All
Local Group Memberships *Administrators
Global Group memberships *None
As you can see, all the details for this user on this computer are listed.
net user rodriguezr /times:MF,7AM-4PM;Sa,8AM-12PM
Below is an example of the login date and time changing for a rodriguezr account.
net user nadeema r28Wqn90 /add /comment:"Basic user account." /fullname:"Ahmed Nadeem" /logonpasswordchg:yes /workstations:jr7tww,jr2rtw /domain
We want to throw the kitchen sink at you with this one. This is the kind of network user application you'll probably never use at home, but you'll likely see it in the scripts your company's IT department distributes for new users.
Here we set up a new user account named nadeema and set the initial password to r28Wqn90 . This is our company's standard account, which we indicate in the account itself [ /comment: " Basic User Account. " ], and is the new HR Director Ahmed [ /full name: " Ahmed Na Dim ” ].
We want Ahmed to change his password to something he won't forget, so we want him to set his own password [ /logonpasswordchg:yes ] when he first logs in. Additionally, Ahmed only has access to two computers in the human resources office [ /workstations: jr7twwr , jr2rtwb ]. Finally, our company uses a domain controller [ /domain ], so Ahmed's account should be set up there.
As you can see, the net user command is used for more than simple user account addition, change, and deletion. We configured several advanced aspects of Ahmed's new account directly from the command prompt.
net user nadeema /delete
Now, we'll end on a simple note. Ahmed [ nadeema ] was not the latest HR member, so he was fired and his account was deleted [ /delete ].
You can use the net user command from the command prompt in most versions of Windows, including Windows 10, Windows 8, Windows 7, Windows Vista, Windows XP, Windows Server operating systems, and some older versions of Windows.
The net user command is a subset of the net command and is therefore similar to its sister commands, such as net use, net time, net send, net view, etc.