How to use the Net Use command in Windows
The `net use` command is a Command Prompt command used to connect to, remove, and configure connections to shared resources, such as mapped drives and network printers.
That's one of many net commands like net send, net time, net user, net view, etc.
What is the net use command?
The NetUse command is a command-line tool introduced in Windows 2000. It is now available in all subsequent versions of the Windows operating system. The NetUse command is used to manage network connections. This command can be used to map network hard drives, connect to shared folders, disconnect from shares, etc.
The Net Use command is quite useful because it can be used to automate many different tasks related to network management. For example, you can use the Net Use command to connect to or disconnect shared resources, display information, and set user-specific settings.
Availability of the net use command
This command is available in Command Prompt on Windows 10 , Windows 8 , Windows 7 , Windows Vista, and Windows XP , as well as in older versions of Windows and in Windows Server operating systems.
The Recovery Console, the offline repair utility in Windows XP, also includes the net use command, but you cannot use it within this tool.
Note : The availability of certain command switches and other command syntax may vary between operating systems.
The syntax of the net use command is
This command uses the following general syntax:
net use [{devicename | *}] [computernamesharename[volume] [{password | *}]] [/user:[domainname]username] [/user:[dotteddomainname]username] [/user:[username@dotteddomainname] [/home {devicename | *} [{password | *}]] [/persistent:{yes | no}] [/smartcard] [/savecred] [/delete] [/help] [/?] The net command options use:
| Options | Explain |
| net card | Execute the `net use` command only to display details about the currently mapped drives and devices. |
| Bankname | Use this option to specify the drive letter or printer port you want to map to a network resource. For a shared folder on a network, specify a drive letter from D: to Z:, and for a shared printer, LPT1: to LPT3:. Use * instead of specifying a devicename to automatically assign the next available drive letter, starting with Z: and going backward, to a mapped drive. |
| computername cashew | This specifies the name of the computer, computername , and the shared resource, sharename , such as a shared folder or a shared printer connected to computername . If there is space here, remember to enclose the entire path, including the slash, in quotation marks. |
| volume | Use this option to specify the volume when connecting to a NetWare server. Client Service for NetWare or Gateway Service for NetWare must be installed. |
| password | This is the password required to access the shared resource on computername . You can choose to enter the password while executing the net use command by typing * instead of the actual password. |
| /user | Use this `net` command option to specify a username to connect to the resource. If you don't use ` /user` , `net use` will attempt to connect to the network share or printer using your current username. |
| domainname | Specify a different domain than the one you are currently using, assuming you are using a domain, with this option. Omit domainname if you are not on a domain or you want to use net use to utilize your existing domain. |
| username | Use this option with /user to specify the username to use to connect to the shared resource. |
| dotteddomainname | This option specifies the eligible domain where the username already exists. |
| hot | The `net use` command option maps the current user's home directory to the drive letter `devicename` or the next available drive letter followed by *. |
| /persistent: { yes | no } | Use this option to control the stability of connections created using the net use command. Select yes to automatically restore created connections on the next login, or select no to limit the connection's lifespan to this session. You can shorten this switch to /p if desired. |
| /smartcard | This switch allows the net use command to utilize the login credentials available on the smart card. |
| /savecred | This option stores the password and user information for use the next time you connect in this session or in all future sessions when used with /persistent:yes . |
| /delete | The `net use` command is used to disconnect from a network. Use `/delete` with `devicename` to delete a specified connection, or with ` *` to delete all mapped drives and devices. This option can be shortened to `/d` . |
| /help | Use this option, or shorten it to /h , to display detailed help information for the net use command. Using this switch is the same as using the net help command with net use: net help use . |
| /? | The standard help switch also works with the net use command, but it only displays the command syntax, without any detailed information about the command's options. |
- Learn about the Attrib command.
How to use the Net Use command in Windows
Here are the steps you need to take to use the Net Use command in Windows:
Step 1 : Go to Command Prompt and type net use .
Step 2 : The Net Use command will display the current connections if no parameters are specified.
Step 3 : If you want to see the available options with the Net Use command, you need to type net use /? or net use /help and press Enter . If you want to know more about a specific connection, you can also use the /? option. For example, for the 'Persistent' option , you need to type net use /? Persistent and press Enter.
Examples of the net use command
Here are some different ways you can use this command:
The drive is temporarily mapped.
net use * "servermy media" /persistent:no In this example, the `net use` command is used to connect to the `my media` shared folder on the computer named ` server` . The `my media` folder will be mapped to the highest available drive letter [*] , in this example `y:`, but will not continue to map this drive every time the computer logs in [/persistent:no] .
Permanent mapping
net use e: usrsvr002smithmark Ue345Ii /user:pdc01msmith2 /savecred /p:yes The above is a slightly more complex example that you might see in a business environment.
In this net use command example, the author wants to map their e: drive to the smithmark shared folder on usrsvr002. The author wants to connect as another existing user account using the username msmith2 hosted on domain pdc01 with the password Ue345Ii. The author does not want to manually map this drive every time the computer starts up , nor does they want to enter the username and password every time .
List all shared sources.
net use In this simple example of the `net use` command, you get a list of all shared resources currently in use under the logged-in user account. In the example, the result in Command Prompt shows "Z:servershared folder" because z: is the drive letter connecting to the shared folder on the server.
The message "There are no entries in this list." will be displayed if no connections are currently established.
Remove a mapping from a drive.
net use p: /delete The final example of net use is deleting the currently mapped drive, in this case, p: .