Add a new user via command-line in Windows

How to Add a new user via command-line in windows, make them a local admin and set their password to never expire.

Create the user account…

This works on both workstations and servers if you add the /domain argument. Here is the command I use to create a domain user account for a user named “Trogdor” with the password  “theBurninator”.

c:\>net user Trogdor theBurninator /add /domain

Here is the full output of the help command for the net user command:

C:\>net user /?
The syntax of this command is:
NET USER
[username [password | *] [options]] [/DOMAIN]
username {password | *} /ADD [options] [/DOMAIN]
username [/DELETE] [/DOMAIN]

Make them a local admin…

Often, however, I want to add the newly created user to the Local Administrators Group. Again, I like to do this from the command line thusly:

c:\>net localgroup administrators Trogdor /add

Password expiration is lame on a personal computer, here is how to fix that…

And, finally, I would like to make it so that the password does not expire. This is possible via the command-line, but it isn’t via the net user command, instead it must be done with a WMIC command. Here is an example below:

c:\>wmic useraccount where “name=’Trogdor'” set passwordexpires=false

The output on the WMIC command is a little more verbose, see below what the output should look like in Windows 10:

C:\>wmic useraccount where “name=’jp'” set passwordexpires=false
Updating property(s) of ‘\\COMPUTERNAME\ROOT\CIMV2:Win32_UserAccount.Domain=”COMPUTERNAME”,Name=”Trogdor”‘
Property(s) update successful.

Article written by Jesse Perry (JP)

Hi there, I am Jesse Perry. I have run an IT Service business for over a decade, been working in the Computer Industry for much longer.

Please comment with your real name using good manners.

Leave a Reply