Some times we may want to add new users from command line instead of using the UI. For example, if we have to add some 100 users, using a script will save lot of time and manual effort. Windows provides net user command for this purpose. This command works on Windows 2000, Windows XP/2003, Vista and Windows 7.
To add a new user account on the 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
To add a new user account to the domain:
net user username password /ADD /DOMAIN
Note that the command does not include the domain name.
net user John fadf24as /ADD /DOMAIN
Rename a user account
We can use below wmic command to rename a user accoun.
wmic useraccount where "name='username' " rename new_username
Ex: To rename the user account techblogger as win7techblogger
wmic useraccount where "name='techblogger' " rename win7techblogger
Net use command does not have any switches to rename a user account.
Few more Advanced uses of net user command.
To specify user full name while creating the user account
net user username userpasswd /ADD /FULLNAME:"User_Fullname"
To specify that the user is allowed to change the password
net user username userpasswd /ADD /PASSWORDCHG:Yes
To restrict user not to change the password:
net user username userpasswd /ADD /PASSWORDCHG:NO
To specify when the account expires we can use /EXPIRES switch.
To specify if the user must have a password set we can use /PASSWORDREQ switch.
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.