User Tools

Site Tools


windows:windows_localuser

Windows create a local user in command line

Use cmd command line

To add a new user account on the local computer:

c:\> net user username password /ADD

If you do not want the password to be visible while adding new user account

C:\> net user /add John *
Type a password for the user: 
Retype the password to confirm:
The command completed successfully.

To add a new user account to the domain:

C:\> net user username password /ADD /DOMAIN

This adds the user to the Local Administrators Group

C:\> net localgroup administrators [username] /add

To set user full name while creating the user account

C:\> net user username password /ADD /FULLNAME:"User_Fullname"

To allow user to change password:

C:\> net user username password /ADD /PASSWORDCHG:Yes

To restrict user not to change the password:

C:\> 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

To make it mandatory to change the password, you can use the switch /LOGONPASSWORDCHG

Example

C:\> net user user1 "passwd@123″ /ADD /FULLNAME:"James User" /comment:"server support enginer" /LOGONPASSWORDCHG:yes
windows/windows_localuser.txt · Last modified: 2021/07/26 11:53 by manu