Windows operating systems provide the
net user command in order to manage user and user account-related configurations via the command-line interface. The “net user” command provides practical usage without the need for the GUI. As the “net user” command is related to user management it may sometimes require Administrative privileges.
“net user” Command Syntax
The “net user” command has the following simple syntax.
net user USER OPTIONS
- The USER is the user account name.
- OPTIONS are single or multiple options with their parameters or values.
List All User Accounts
All existing user accounts can be listed by using the
net user command. There is no need for the extra parameter.
> net user
Display User Account Information
The “net user” command can be used to list detailed user information. The user name is provided as a parameter. In the following example, we list detailed user information for the “ismail”.
> net user ismail
User name ismail Full Name Comment User's comment Country/region code 000 (System Default) Account active Yes Account expires Never Password last set 5/13/2022 9:54:12 AM Password expires Never Password changeable 5/13/2022 9:54:12 AM Password required No User may change password Yes Workstations allowed All Logon script User profile Home directory Last logon 5/13/2022 9:51:59 AM Logon hours allowed All Local Group Memberships *Administrators *docker-users Global Group memberships *None
Change User Account Password
One of the most popular use cases for the “net user” command is the ability to change the user passwords via the command-line interface. The syntax of the “net user” command to change password is like below.
net user USER PASSWORD
In the following example, we set the user “ismail” password as “123456Ww.”.
> net user ismail 123456Ww.
The current user has the privilege to change their own password or the Administrator user can change the password without error. But if a regular user tries to change another user’s password he may get “System error 5 has occurred. Access is denied” error. This means the command-line interface (MS-DOS or PowerShell) should be opened with administrator privileges which are described in the following post.
Change Domain User Account Password
The “net user” command can be also used to manage domain users. A domain user password can be changed using the “net user” command. The syntax to change the domain user password is like below.
net user USER * /domain
In the following example, we change the domain user’s “ismail” password. The password is requested interactively for two times via the command prompt.
> net user ismail * /domain
Disable User Account
The user account can be disabled or deactivated using the “net user” command. The
/Active:No option is used to disable an account. The account is not deleted but disabled which means can not be used unless activated.
> net user ismail /Active:No
The domain user account can be also disabled like below where the
/domain option is added to the previous command.
> net user ismail /Active:No /domain
Enable User Account
A deactivated or disabled user account can be enabled using the
> net user ismail /Active:Yes
Display User Full Name
User account names are generally different than the user’s actual or full name. Just list user accounts and all information and take look at the
full name line. The
Find command can be used to filter only the full name line like below.
> net user ismail | Find /i "full name"
Set Home Directory For User Account
Most Windows user has their own home directories in order to store their personal data which can not be accessed by other users. The “net user” command can be used to set the home directory for the user account easily.
> net user ismail /domain /add /homedir:C:\users\ismail
Add Comment For User Account
In some cases, we may want to add some comments to the user account. The
/comment option can be used to set comments for a user account. The syntax of adding comments for a user account is like below.
> net user USER /comment:COMMENT
In the following example, we set the comment for the user account “ismail”.
> net user ismail /comment:"This is temporary user"
Set Expire Date For User Account
By default, user accounts do not expire. But we can set the expiry dates for user accounts.
> net user ismail /expires:21/12/2022