Net user command details (add user under DOS)

Time:2020-11-4

Net user

Add or modify user accounts or display user account information.

grammar

net user [UserName [Password | *] [options]] [/domain]

net user [UserName {Password | *} /add [options] [/domain]]

net user [UserName [/delete] [/domain]]

parameter

UserName
Specifies the name of the user account to add, delete, modify, or view. The user account name can be up to 20 characters.
Password
Assign or change a password for a user account. Enter an asterisk (*) to generate a password prompt. The password is not displayed when you type the password at the password prompt line.
/domain
Performs operations on the primary domain controller of the computer’s primary domain.
options
Specify command line options. The following table lists the valid command-line options that you can use.

Command line options syntax
explain

/active:{no | yes}
Enable or disable user accounts. If the user account is inactive, the user cannot access resources on the computer. The default setting is yes (i.e. active state).

/comment:”text”
Provide a descriptive description of the user’s account. The comment can be up to 48 characters long. Put quotation marks on the text.

/countrycode:nnn
Use the operating system “country (region)” code to implement the specified language file for user help and error messages. The value 0 represents the default country code.

/expires:{{mm/dd/yyyy | dd/mm/yyyy | mmm,dd ,yyyy} | never}
Causes the user account to expire on the specified date. The expiration date can be in the format of [mm / DD / yyyy], [DD / mm / yyyy], or [mmm, DD, yyyy]. It depends on the country code. Note that the account expires at the beginning of the specified date. For month values, you can use numbers, full names, or three letter abbreviations (i.e., Jan, Feb, Mar, APR, may, Jun, Jul, Aug, Sep, Oct, Nov, DEC). For year values, you can use two or four digits. Use commas and slashes to separate parts of the date. Do not use spaces. If yyyy is omitted, it is assumed to be the date of the next occurrence (depending on the date and time of the computer). For example, if the date entered is between January 10, 1994 and January 8, 1995, the following date entries are equal:
jan,9
1/9/95
january,9,1995
1/9

/fullname:”name”
Specify the full name of the user, not the user name. Enclose the name in quotation marks.

/homedir:Path
Set the path of the user’s home directory. The path must exist.

/passwordchg:{yes | no}
Specifies whether users can change their own passwords. The default setting is yes.

/passwordreq:{yes | no}
Specifies whether the user account must have a password. The default setting is yes.

/profilepath:[Path]
Set the path to the user login profile. The path points to the registry configuration file.

/scriptpath:Path
Set the path of the user login script. Path cannot be an absolute path. Path is the relative path of% systemroot% \ system32 \ \ repl / import / scripts.

/Times: {day [- day] [, day [- day]], time [- time] [, time [- time]] [; | all}
Specifies the time that users can use the computer. The increment value of time is limited to 1 hour. For day values, you can use full names or abbreviations (i.e., m, t, W, th, F, SA, Su). You can use the 12 hour or 24-hour time representation. For 12 hour notation, use am, PM, or a.m., p.m. A value of all indicates that the user can always log in. A null value (blank) means that the user will never be able to log in. Separate the date and time with commas and the date and time units with semicolons (for example, m, 4am-5pm; t, 1pm-3pm). Do not use spaces when specifying the time.

/usercomment:”text”
Specifies that the administrator adds or changes user notes for the account. Put quotation marks on the text.

/workstations:{ComputerName[,…] | *}
List up to 8 workstations that users can log on to the network. Separate multiple items in the list with commas. If / workstations does not have a list, or the list is asterisk *, the user can log in from any computer.

net help command
Displays help for the specified net command.

notes

If used without parameters, net user displays a list of user accounts on the computer. You can also type net users.
The password must meet the minimum length requirements set in net accounts / minpwlen. It can be up to 127 characters. However, if the computer running Windows 2000 or Windows XP is on a network with another computer running Windows 95 or Windows 98, consider using a password of no more than 14 characters. Windows 95 and windows 98 support passwords of up to 14 characters. If the password is too long, you may not be able to log on to the network from those computers.

example

To display a list of all user accounts on the local computer, type:
net user
To view information about the user account jimmyh, type:
net user jimmyh
To add a user account for Jay Jamison, login rights are from 8:00 a.m. to 5:00 p.m. from Monday to Friday (there is no interval in the time specification), and use the mandatory password (jayj) and the full name of the user, type:
net user jayj /add /passwordreq:yes /times:monday-friday,8am-5pm/fullname:”Jay Jamison”
To set the login time for johnsw (8:00 a.m. to 5:00 p.m.) using the 24-hour notation, type:
net user johnsw /time:M-F,08:00-17:00
To set the login time for johnsw (8am to 5pm) using the 12 hour notation, type:
net user johnsw /time:M-F,8am-5pm
To specify that the login hours for marysl are 4:00 a.m. to 5:00 p.m. on Monday, 1:00 p.m. on Tuesday, and 8:00 a.m. to 5:00 p.m. on Wednesday through Friday, type:
net user marysl /time:M,4am-5pm;T,1pm-3pm;W-F,8:00-17:00
XOX

Through net localgroup / add administrators ABC, ABC is added to the administrators user group to realize the promotion from ordinary users to administrator users. For more information, please refer to the developeppaer article.