Skip to main content

Batch Script Net Use

Net Use

net use command 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:[<DottedDomainName>\]<UserName>] [/user: [<UserName@DottedDomainName>] [/savecred] [/smartcard] [{/delete | /persistent:{yes | no}}] 
net use [<DeviceName> [/home[{<Password> | *}] [/delete:{yes | no}]]
net use [/persistent:{yes | no}]

where:

  • <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 or Gateway Service for Netware (Windows Server) 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.

Examples

To assign the disk-drive device name E: to the Letters shared directory on the \\Financial server, type:

net use e: \\financial\letters

To assign (map) the disk-drive device name M: to the directory User2 within the Letters volume on the \\Financial server, type:

net use m: \\financial\letters\User2

To connect the user identifier User1 as if the connection were made from the Accounts domain, type:

net use d:\\server\share /user:Accounts\User1

To disconnect from the \\Financial\Public directory, type:

net use f: \\financial\public /delete

To connect to the resource memos shared on the \\Financial 2 server, type:

net use k: "\\financial 2" \memos

To restore the current connections at each logon, regardless of future changes, type:

net use /persistent:yes

Table of Contents