Adding users from command line is much easier rather than going through UI. It saves lot of time for Windows admins to add users in bulk using CLI commands/script.
Net user command is the one that Windows users can use to manage user accounts, read on to know how to add users from CMD.
To add a new user account on local computer:
net user username password /ADD
Example: To add a new user account with the loginid John and with password fadf24as
net user John fadf24as /ADD
If you do not want the password to be visible while adding new user account, you can use ‘*’ as shown below.
C:\>net user /add John * Type a password for the user: Retype the password to confirm: The command completed successfully. C:\>
To add a new user account to the domain:
net user username password /ADD /DOMAIN
Note that the command does not include the name of the domain, it automatically adds to the domain the computer belongs to.
net user John fadf24as /ADD /DOMAIN
Rename a user account
Net use command does not have any switches to rename a user account. But we can do that using wmic commands. Please check this – Rename user accounts on Windows
Few more advanced uses of net user command.
To set user full name while creating the user account
net user username password /ADD /FULLNAME:"User_Fullname"
To allow user to change password:
net user username password /ADD /PASSWORDCHG:Yes
To restrict user not to change the password:
net user username userpasswd /ADD /PASSWORDCHG:NO
To set account expiry time we can use /EXPIRES switch. This can also be used to set that the account never expires.
To specify if the user must have a password set we can use /PASSWORDREQ switch. For more information on all net user options, read this – Net user command: syntax and examples
How to create a new administrator account?
An administrator account can’t be created directly. We first need to create a user account and then add the user to the administrators group.
- If you don’t have privileges to add new user account to the system, you would get an error like below.
C:\>net user John /add System error 5 has occurred. Access is denied. C:\>
- While adding user to domain, make sure that your computer is connected to the domain. Otherwise it throws up below error.
C:\>net user testuser testpassword /ADD /DOMAIN The request will be processed at a domain controller for domain mydomain.com. System error 1355 has occurred. The specified domain either does not exist or could not be contacted.