Batch script has the facility to work with network settings. The NET command is used to update, fix, or view the network or network settings. This chapter looks at the different options available for the net command.
NET ACCOUNTS
View the current password & logon restrictions for the computer.
Syntax
NET ACCOUNT [/FORCELOGOFF:{minutes | NO}] [/MINPWLEN:length] [/MAXPWAGE:{days | UNLIMITED}] [/MINPWAGE:days] [/UNIQUEPW:number] [/DOMAIN]
Wherein
FORCELOGOFF − Force the log-off of the current user within a defined time period.
MINPWLEN − This is the minimum password length setting to provide for the user.
MAXPWAGE − This is the maximum password age setting to provide for the user.
MINPWAGE − This is the minimum password age setting to provide for the user.
Example
NET ACCOUNT
Output
Force user logoff how long after time expires?: Never Minimum password age (days): 0 Maximum password age (days): 42 Minimum password length: 0 Length of password history maintained: None Lockout threshold: Never Lockout duration (minutes): 30 Lockout observation window (minutes): 30 Computer role: SERVER The command completed successfully.
NET CONFIG
Displays your current server or workgroup settings.
Syntax
NET CONFIG
Example
NET CONFIG
Output
The following running services can be controlled: Server Workstation The command completed successfully.
NET COMPUTER
Adds or removes a computer attached to the windows domain controller.
Syntax
NET COMPUTER \\computername {/ADD | /DEL}
Example
NET COMPUTER \\dxbtest /ADD
Output
The above command will add the machine with the name dxbtest to the domain in which the windows domain controller exists.
NET USER
This command can be used for the following −
- View the details of a particular user account.
- Add a user account.
- Delete a user’s account.
- Modify a user’s account.
Syntax
Net user [username [password | *] [options]] [/DOMAIN] username {password | *} /ADD [options] [/DOMAIN] username [/DELETE] [/DOMAIN]
Example
NET USER
The above command shows all the accounts defined on a system. Following is the output of the above command.
User accounts for \\WIN-50GP30FGO75 ------------------------------------------------------------------------------- Administrator atlbitbucket Guest The command completed successfully.
net user Guest
The above command shows the details of Guest account defined on a system. Following is the output of the above command.
Output
User name Guest Full Name Comment Built-in account for guest access to the computer/domain User's comment Country/region code 000 (System Default) Account active No Account expires Never Password last set 1/4/2016 9:34:25 AM Password expires Never Password changeable 1/4/2016 9:34:25 AM Password required No User may change password No Workstations allowed All Logon script User profile Home directory Last logon Never Logon hours allowed All Local Group Memberships *Guests Global Group memberships *None The command completed successfully.
NET STOP/START
This command is used to stop and start a particular service.
Syntax
Net stop/start [servicename]
Example
NET STOP SpoolerThe above command is used to stop the printer spooler service. Following is the output of the above command.
The Print Spooler service is stopping. The Print Spooler service was stopped successfully. NET START SpoolerThe above command is used to start the printer spooler service. Following is the output of the above command.
The Print Spooler service is starting. The Print Spooler service was started successfully.
NET STATISTICS
Display network statistics of the workstation or server.
Syntax
Net statistics [SERVER/WORKSTATION]
Example
Net statistics ServerOutput
Server Statistics for \\WIN-50GP30FGO75 Statistics since 1/3/2016 9:16:28 PM Sessions accepted 0 Sessions timed-out 0 Sessions errored-out 0 Kilobytes sent 0 Kilobytes received 0 Mean response time (msec) 0 System errors 0 Permission violations 0 Password violations 0 Files accessed 0 Communication devices accessed 0 Print jobs spooled 0 Times buffers exhausted Big buffers 0 Request buffers 0
NET USE
Connects or disconnects your computer from a shared resource or displays information about your connections.
Syntax
NET USE [devicename | *] [\\computername\sharename[\volume] [password | *]] [/USER:[domainname\]username] [/USER:[dotted domain name\]username] [/USER:[username@dotted domain name] [/SMARTCARD] [/SAVECRED] [[/DELETE] | [/PERSISTENT:{YES | NO}]]
where
\\computername\sharename − This is the name of the share which needs to be connected to.
/USER − This needs to be specified to ensure that the right credentials are specified when connecting to the network share.
Example
net use z: \\computer\test
The above command will connect to the share name \\computer\test and assign the Z: drive name to it.
沒有留言:
張貼留言