The windows net use command is a quick way to discover any shared resources on a computer or server.

The Net Use command is a pretty old command that is still commonly used to connect network drives in Windows. The advantage of the Net Use command is that it allows you to quickly add, view, and delete network resources from your computer.

The command is capable of connecting to all kinds of network resources. But most of the time it’s used to connect to network shares.

In this article, we are going to take a closer look at the Net Use command. I will explain how you can view, add, and delete network shares from the cmd line.

Net Use Command

Before we are going to take a look at how to add a network drive, we first going to list the existing connections. If you simply type the command Net Use you will get an overview of all existing network connections and their status.

Now you could also open the explorer to see all network drivers. But the advantage of Net Use is that it will also list any hidden network connections that are created with a group policy.

Open command prompt or PowerShell and type:

Net Use

This will show a list of all connections and the status of the connection:

The windows net use command is a quick way to discover any shared resources on a computer or server.
net use command

We can also view the details of each connection with net use <driveletter>. This is really handy if you want to check if a particular network drive is currently used or you want to know more about the resource type.

# Type Net use followed by the drive letter Net Use X:
The windows net use command is a quick way to discover any shared resources on a computer or server.

Add Network Connection with Net Use

The Net Use command is commonly used to add or remove network connections from a computer. One of the advantages of using a command for this is that you can add a drive letter after somebody logs in. Or easily create a script that will add the network connection on multiple computers.

Let’s start with simply adding a network drive to the computer. We are going to make a connection to the \\VBoxSvr\Win11\Documents and assign the drive letter H: to it. \\VBoxSvr is the name of the computer or server. Win11 is the shared folder and Documents is a subfolder.

Net use h: \\VBoxSvr\Win11\Documents

After you have run the command you will see the drive mapping in the explorer.

You can choose any available drive letter from A to Z (c is often taken for your system drive) for shared folders and LTP1: to LTP3: for printers. It’s also possible to automatically assign a drive letter by using * . This way the Net Use command will automatically select the highest available drive letter, starting with Z:

# Pick the first available drive letter: Net use * \\VBoxSvr\Win11\Documents

Net Use Persistent

By default, the network resources that you add with Net Use are only temporarily. After you log off or reboot the mapping will be gone. However, most of the time you want the drive mapping to be persistent.

To make a drive mapping persistent we will need to add the parameter /persistent:yes to the command:

Net use h: \\VBoxSvr\Win11\Documents /persistent:yes # or in short: Net use h: \\VBoxSvr\Win11\Documents /p:yes

Note

All other drive mappings that you add in the same session after you have used /persistent:yes will also be persistent. So to make a temporarily drive mapping after a persisitent one, you will need to use /persistent:no

Mapping Network Drive with different credentials

Your computer will use your current credentials when mapping a shared network folder. But often you will need to supply different credentials for the network resource. With Net Use we can supply the username and password that needs to be used to open the network resource.

It’s possible to enter the password as plain text in the command:

# Authenticate with the username VboxSrv\user1 and password Passwrd123 Net use h: \\VBoxSvr\Win11\Documents /user:VboxSrv\user1 Passwrd123 /p:yes

But another option is to use a * symbol, after which you will be prompted to enter the password:

Net use h: \\VBoxSvr\Win11\Documents /user:VboxSrv\user1 * /p:yes

The only problem with this is that the password is forgotten after a reboot. So you will need to reenter the password every time you open the network connection. We can solve this by using the parameter /savecred.

There is one catch, however, to use /savecred you must not supply the username and password. Otherwise, you get the error “A command was used with conflicting switches”. The /savecred parameter will use the stored credentials on your computer. If it doesn’t find credentials for the connection it will ask for it:

PS C:\> net use * \\VBoxSvr\Win11 /savecred /p:yes Enter the user name for 'VBoxSvr': lazyadmin\user01 Enter the password for VBoxSvr: Drive Y: is now connected to \\VBoxSvr\Win11. The command completed successfully.

Unmap Network Drive

We can also use the Net Use command to unmap a network drive in Windows. The first step is to list the existing connections by simply typing net use in the command prompt or PowerShell window.

Next, we can type net use followed by the drive letter that we want to remove. Instead of a drive letter, you can also supply the remote target path:

Net use Y: /delete # Or Net use \\VboxSvr\Win11 /delete

The windows net use command is a quick way to discover any shared resources on a computer or server.
unmap network drive

Mapping users home directory

When the user’s home directories are stored on a network share then you can easily map their home folder with the net use command. For this, you will need to have a domain with the home directory path configured in the Active Directory.

To map the user’s home folder you use the following command:

Net Use h: /home

Wrapping Up

The Net Use command is an old but useful command. I still use it often to get a quick overview of the mapped (hidden) network drives on computers or in local home networks to map a NAS for example.

When using the command, make sure that you use the /persistent:yes parameter so the mapping stays in place after a reboot.

If you have any questions, just drop a comment below.

The net use command is a Command Prompt command used to connect to, remove, and configure connections to shared resources, like mapped drives and network printers.

It's one of many net commands like net send, net time, net user, net view, etc.

This command is available from within the Command Prompt in Windows 11, Windows 10, Windows 8, Windows 7, Windows Vista, and Windows XP, and in older versions of Windows and in Windows Server operating systems.

Net Use Command (Windows 10).

Recovery Console, the offline repair utility in Windows XP, also includes the net use command, but it's not possible to use it within the tool.

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

This command uses the following general syntax:

net use [{devicename | *}] [\\computername\sharename[\volume] [{password | *}]] [/user:[domainname\]username] [/user:[dotteddomainname\]username] [/user:[username@dotteddomainname] [/home {devicename | *} [{password | *}]] [/persistent:{yes | no}] [/smartcard] [/savecred] [/delete] [/help] [/?]

Review how to read command syntax if you're not sure how to interpret the net use command syntax as it's shown above or described in the table below.

Net Use Command Options
Option Explanation
net use Execute the net use command alone to show detailed information about currently mapped drives and devices.
devicename Use this option to specify the drive letter or printer port you want to map the network resource to. For a shared folder on the network, specify a drive letter from D: through Z:, and for a shared printer, LPT1: through LPT3:. Use * instead of specifying devicename to automatically assign the next available drive letter, starting with Z: and moving backward, for a mapped drive.
\\computername\sharename This specifies the name of the computer, computername, and the shared resource, sharename, like a shared folder or a shared printer connected to computername. If there are spaces anywhere here, be sure to put the entire path, slashes included, in quotes.
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 needed to access the shared resource on computername. You can choose to enter the password during the execution of 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 with. If you don't use /user, net use will attempt to connect to the network share or printer with your current username.
domainname Specify a different domain than the one you're on, assuming you're on one, with this option. Skip domainname if you're not on a domain or you want net use to use the one you're already on.
username Use this option with /user to specify the username to use to connect to the shared resource.
dotteddomainname This option specifies the fully qualified domain name where username exists.
/home This net use command option maps the current user's home directory to either the devicename drive letter or the next available drive letter with *.
/persistent:{yes | no} Use this option to control the persistence of connections created with the net use command. Choose yes to automatically restore created connections at the next login or choose no to limit the life of this connection to this session. You can shorten this switch to /p if you like.
/smartcard This switch tells the net use command to use the credentials present on the available smart card.
/savecred This option stores the password and user information for use next time you connect in this session or in all future sessions when used with /persistent:yes.
/delete This net use command is used to cancel a network connection. Use /delete with devicename to remove a specified connection or with * to remove all mapped drives and devices. This option can be shortened to /d.
/help Use this option, or the shortened /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 only displays the command syntax, not any detailed information about the command's options.

Following are a few different ways you might use this command:

net use * "\\server\my media" /persistent:no

In this example, we used the net use command to connect to the my media shared folder on a computer named server. The my media folder will be mapped to the highest available drive letter [*], which in our example happens to be y:, but we don't want to continue mapping this drive every time we log onto the computer [/persistent:no].

net use e: \\usrsvr002\smithmark Ue345Ii /user:pdc01\msmith2 /savecred /p:yes

The above is a slightly more complicated example that you might see in a business setting.

In this net use example, we want to map our e: drive to the smithmark shared folder on usrsvr002. We want to connect as another user account we have [/user] by the name of msmith2 that's stored on the pdc01 domain with a password of Ue345Ii. We don't want to map this drive manually every time we start the computer [/p:yes], nor do we want to enter the username and password each time [/savecred].

net use

In this simple example of the net use command, we get a list of all the shared resources currently in use under the user account that's currently logged in. In our example, the result in Command Prompt shows "Z: \\server\shared folder\" since z: is the drive letter that's connecting to shared folder on server.

The message "There are no entries in this list." will show if there aren't any connections currently set up.

net use p: /delete

An appropriate final example of net use is the removal [/delete] of a currently mapped drive, in this case, p:.

Thanks for letting us know!

Subscribe

Tell us why!