Windows

Windows / Windowskommandon

Net command info

What is the Net Command?

The net command is a Command Prompt command that can be used to manage almost every aspect of a network and its settings including managing network shares, network print jobs, network users, and much more.

Net Command Syntax

net [accounts | computer | config | continue | file | group | help | helpmsg | 
localgroup | name | pause | print | send | session | share | start | statistics | 
stop | time | use | user | view]

Net Command - Commands overview

Net Accounts
The net accounts command is used to set password and logon requirements for users. For example, the net accounts command can be used to set the minimum number of characters that users can set their password to.

Net Computer
The net computer command is used to add or remove a computer from a domain.

Net Config
Use the net config command to show information about the configuration of the Server or Workstation service.

Net Continue
The net continue command is used to restart a service that was put on hold by the net pause command.

Net File
Net file is used to show a list of open files on a server. The command can also be used to close a shared file and remove a file lock.

Net Group
The net group command is used to add, delete, and manage global groups on servers.

Net Help
The net help command is used to get detailed help on each of the net subset commands. net help *command* : Displays help for the specified net command.

For example, executing net help user shows detailed information about how to use the net user command. Executing net user /help or net user /h accomplishes the same thing. The standard /? help switch is also available for each net subset command but doesn't provide near the information that /help does.

Net Helpmsg
The net helpmsg is used to display more information about the numerical network messages you might receive when using net commands. For example, when executing net group on a standard Windows workstation, you'll receive a 3515 help message. To decode this message, type net helpmsg 3515 which displays "This command can be used only on a Windows Domain Controller." on screen.

Net Localgroup
The net localgroup command is used to add, delete, and manage local groups on computers.

Net Name
Net name is used to add or delete a messaging alias at a computer. The net name command was removed in conjunction with the removal of net send beginning in Windows Vista. See the net send command for more information.

Net Pause
The net pause command puts on hold a Windows resource or service.

Net Print
Net print is used to display and manage network print jobs. The net print command was removed beginning in Windows 7. According to Microsoft, the tasks performed with net print can be performed in Windows 8 and Windows 7 using the prnjobs.vbs and other cscript commands, Windows PowerShell cmdlets, or Windows Management Instrumentation (WMI).

Net Send
Net send is used to send messages to other users, computers, or net name created messaging aliases. The net send command is not available in Windows 8, Windows 7, or Windows Vista but the msg command accomplishes the same thing.

Net Session
The net session command is used to list or disconnect sessions between the computer and others on the network.

Net Share
The net share command is used to create, remove, and otherwise manage shared resources on the computer.

Net Start
The net start command is used to start a network service or list running network services.

Net Statistics
Perhaps one of the most useful Net commands is Net Statistics. The Net Statistics command provides some hard-core statistics on how a server or workstation is communicating across the network. This command merely requires you to follow the Net Statistics command with the word Server or Workstation. Use the net statistics command to show the network statistics log for the Server or Workstation service.

Examples:

C:\USERS\Administrator>net statistics workstation
C:\USERS\Administrator>net statistics server

Net Stop
The net stop command is used to stop a network service.

Net Time
Net time can be used to display the current time and date of another computer on the network.
The Net Time command can also be used to synchronize the time on a workstation with the time on a server. Here’s the syntax for the Net Time command:

NET TIME [\\computer | /WORKGROUP:wgname] [/SET] [/YES]

computer - Specifies the name of the computer (time server) whose time you want to check or synchronize your computer's clock with.

/WORKGROUP — Specifies that you want to use the clock on a computer (time server) in another workgroup.

wgname — Specifies the name of the workgroup containing a computer whose clock you want to check or synchronize your computer's clock with. If there are multiple time servers in that workgroup, NET TIME uses the first one it finds.

/SET — Synchronizes your computer's clock with the clock on the computer or workgroup you specify.

/YES — Carries out the NET TIME command without first prompting you to provide information or confirm actions.

Net Use
Connects a computer to or disconnects a computer from a shared resource, or displays information about computer connections and shared resources on the network that you're currently connected to. The command also controls persistent net connections. Used without parameters, net use retrieves a list of network connections. The net use command can be used to show the shared drives you've mapped to as well as allow you to manage those mapped drives.

Syntax:

net use [{DeviceName | *}] [\\ComputerName\ShareName[\volume]] [{Password | *}]] 
[/user:[DomainName\]UserName] [/user:[DottedDomainName\]UserName] 
[/user: [UserName@DottedDomainName] [/savecred] 
[/smartcard] [{/delete | /persistent:{yes | no}}]
net use [DeviceName [/home[{Password | *}] [/delete:{yes | no}]]
net use [/persistent:{yes | no}]

Parameters:

DeviceName
Assigns a name to connect to the resource or specifies the device to be disconnected. There are two kinds of device names: disk drives (that is, D: through Z:) and printers (that is, LPT1: through LPT3:). Type an asterisk (*) instead of a specific device name to assign the next available device name.

\\ComputerName\ShareName
Specifies the name of the server and the shared resource. If ComputerName contains spaces, use quotation marks around the entire computer name from the double backslash (\\) to the end of the computer name (for example, " \\Computer Name\Share Name"). The computer name can be from 1 to 15 characters long.

\volume
Specifies a NetWare volume on the server. You must have Client Service for NetWare installed and running to connect to NetWare servers.

Password
Specifies the password needed to access the shared resource. Type an asterisk (*) to produce a prompt for the password. The password is not displayed when you type it at the password prompt.

/user
Specifies a different user name with which the connection is made.

DomainName
Specifies another domain. If you omit DomainName, net use uses the current logged on domain.

UserName
Specifies the user name with which to log on.

DottedDomainName
Specifies the fully-qualified domain name for the domain where the user account exists.

/savecred
Stores the provided credentials for reuse.

/smartcard
Specifies the network connection is to use the credentials on a smart card. If multiple smart cards are available, you are asked to specify the credential.

/delete
Cancels the specified network connection. If you specify the connection with an asterisk (*), all network connections are canceled.

/persistent:{yes | no}
Controls the use of persistent network connections. The default is the setting used last. Deviceless connections are not persistent. Yes saves all connections as they are made, and restores them at next logon. No does not save the connection being made or subsequent connections. Existing connections are restored at the next logon. Use /delete to remove persistent connections.

/home
Connects a user to the home directory.

Net User
The net user command is used to add, delete, and otherwise manage the users on a computer. The following example shows the syntax of the net user command: net user [username [password | *] [options]] [/domain] username {password | *} /add [options] [/domain] username [/delete] [/domain]

Parameters:

username
Is the name of the user account you want to add, delete, modify, or view. The name of the user account can have as many as 20 characters.

password
Assigns or changes a password for the user's account. A password must satisfy the minimum length set with the /minpwlen option of the net accounts command. It can contain as many as 14 characters.

*
Produces a prompt for the password. The password is not displayed when you type it at a password prompt.

/domain
Performs the operation on the primary domain controller (PDC) of the current domain. This parameter applies only to computers running Windows NT Workstation that are members of a Windows NT Server domain. By default, Windows NT Server-based computers perform operations on the PDC.

/add
Adds a user account to the user accounts database.

/delete
Removes a user account from the user accounts database.

Options:

/active:{yes | no}
Activates or deactivates the account. If the account is not active, the user cannot gain access to the server. The default is yes.

/comment:"text"
Provides a descriptive comment about the user's account (maximum of 48 characters). Be sure to put quotation marks around the text you use.

/countrycode:nnn
Uses the operating system country code to implement the specified language files for a user's help and error messages. A value of 0 signifies the default country code.

/expires:{date | never}
Causes the account to expire if date is set. The never option sets no time limit on the account. An expiration date is in the form mm/dd/yy or dd/mm/yy, depending on the country code. Months can be a number, spelled out, or abbreviated with three letters. Year can be two or four numbers. Use slashes (/) with no spaces to separate parts of the date.

/fullname:"name"
Is a user's full name (rather than a user name). Enclose the name in quotation marks.

/homedir:pathname
Sets the path for the user's home directory. The path must exist.

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

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

/profilepath[:path]
Sets a path for the user's logon profile.

/scriptpath:pathname
Is the location of the user's logon script.

/times:{times | all}
Is the logon hours. The times option is expressed as day[-day][,day[-day]],time[-time][,time [-time]], and is limited to 1-hour increments. Days can be spelled out or abbreviated. Hours can be 12-hour or 24-hour notation. For 12-hour notation, use am, pm, a.m., or p.m. The all option specifies that a user can always log on, and a blank value specifies that a user can never log on. Separate day and time entries with a comma, and separate multiple day and time entries with a semicolon.

/usercomment:"text"
Lets an administrator add or change the user comment for the account.

/workstations:{computername[,...] | *}
Lists as many as eight computers from which a user can log on to the network. If the /workstations option has no list or if the list is *, the user can log on from any computer.

net help user | more
Displays Help one screen at a time. NOTE: You can obtain all of the information contained in this article by typing the following command: net help user

Net View
Net view is used to show a list of computers and network devices (that are visible) on the network. Tip: You can save to a file whatever a net command shows on screen using a redirection operator with the command. See How To Redirect Command Output to a File for instructions or see Command Prompt Tricks for more tips.

Example:

C:\USERS\Administrator>net view

Net Command Availability

The net command is available from within the Command Prompt in all Windows operating systems including Windows 8, Windows 7, Windows Vista, Windows XP, and more.

Note: The availability of certain net command switches and other net command syntax may differ from operating system to operating system.

Net & Net1

You may have come across the net1 command and wondered what it was, maybe even more baffled that it seems to function exactly like the net command. The reason it seems to act just like the net command is because it is the net command.

Only in Windows NT and Windows 2000 was there a difference in the net command and the net1 command. The net1 command was made available in these two operating systems as a temporary fix for a Y2K issue the net command experienced.

This Y2K issue with the net command was corrected before Windows XP was even released but you'll still find net1 in Windows XP, Vista, 7, and 8 to maintain compatibility with older programs and scripts that used net1 when it was necessary to do so.

Net Related Commands

The net commands are network related commands and so may often be used for troubleshooting or management alongside commands like ping, tracert, ipconfig, netstat, nslookup, and others.

Sources:
http://pcsupport.about.com/od/commandlinereference/p/net-command.htm
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/net_use.mspx?mfr=true
http://support.microsoft.com/kb/251394
http://www.techrepublic.com/article/sample-of-net-view-command/