🌐 🇵🇱 Polski · 🇬🇧 EN
If you need to add a user in Windows using an external tool, such as an automation script, or if you simply prefer managing the system via the CMD console, you can easily do so using only the net user command. To add a user to a group, we use the net localgroup command. How to use these commands is explained below.
The net user command.
The net user command is used to add, remove, modify, and display user account information.
Adding a user is performed as follows:
net user username password /ADD
e.g.: net user test test123! /ADD
The command above will create an account named "test" with the password "test123!" with standard permissions.
To check the information about this account, we run the command:
net user test
The result of the command above:
C:\Windows\system32>net user test
User name test
Full Name
Comment
User's comment
Country code 000 (System default)
Account active Yes
Account expires Never
Password last set 2015-05-07 12:57:53
Password expires 2015-06-18 12:57:53
Password changeable 2015-05-07 12:57:53
Password required Yes
User may change password Yes
Workstations allowed All
Logon script
User profile
Home directory
Last logon Never
Logon hours allowed All
Local Group Memberships *Users
Global Group memberships *None
The command completed successfully.
Above, we can see all the information about the newly created account.
We can also add the newly created account to a group with higher privileges by executing the command:
net localgroup Administrators test /add
Next, we will check what changes have been made to the test user account:
C:\Windows\system32>net user test
User name test
Full Name
Comment
User's comment
Country code 000 (System default)
Account active Yes
Account expires Never
Password last set 2015-05-07 12:57:53
Password expires 2015-06-18 12:57:53
Password changeable 2015-05-07 12:57:53
Password required Yes
User may change password Yes
Workstations allowed All
Logon script
User profile
Home directory
Last logon Never
Logon hours allowed All
Local Group Memberships *Administrators
*Users
Global Group memberships *None
The command completed successfully.
It is now visible that the account has permissions from the Administrators group.
NOTE:
Please note which language version of the system you are working with; if it is the English version, the group will be named "Administrators".
Other options for account modification:
- /active:{yes | no} - switch to mark whether the account should be active or not.
- /comment:"comment text" - add a description for the account.
- /countrycode:nnn - set the country code for the user, which configures language files, Windows help language versions, and error message languages.
- /expires:{date | never} - set the account expiration date.
- /fullname:"full account name" - set the full account name.
- /homedir:path - set the location of the user's home directory.
- /passwordchg:{yes | no} - specify whether the user can change their password.
- /passwordreq:{yes | no} - specify whether the account must have a password or not.
- /profilepath:[:path] - specify the profile to which the user will be logged in.
- /scriptpath:path name - specify the location of the logon script.
- /times:{times| all} - switch to specify the time format.
- /usercomment:"comment text" - comment for the user account.
- /workstations:{host name[....], | *} - list of hosts to which this user can log in over the network.

Comments