How To Use Net Use Command In Windows Command Line?
Windows operating systems provide the
net use command in order to connect ,remove, configure connections to the shared resources like mapped drives, network resources and network printers.
net use command is used from command line and provided operating systems Windows XP, Windows 7, Windows 8, windows 10 and Windows Servers from 2003 to 2019 .
net use command has following usage syntax. We will provide the drive name and the path we want to use.
net use DRIVE: PATH
DRIVE:is the name of the drive like
:Zetc. used with local system.
PATHis the remote resource we want to use which will provide the IP address or hostname with resource URI. Example \\192.168.1.20\test
We can get some help about
net use command by using
/? parameters like below.
> net use /?
List Currently Existing Shares
We will start by listing currently existing, joined or mounted remote shares. We will just use
net use command like below.
> net use
Join or Mount A Remote File Share
We will start with a simple example by mounting a remote file share into our local system. We will mount file share named
Backup which resides at
> net use z: \\192.168.145.162\Backup
Join File Share with Specified User
In previous example we have mounted remote file share with the current user and privileges. In some cases we may need to mount with a different user than current session user. We can specify the user we want to use with
/USER option. In this example we will use user
> net use z: \\192.168.145.162\Backup /USER:Administrator
There will also also some information about the mount like Status, Connections, Resource type.
OR we can also provide the user password explicitly. Keep in mind that providing password in clear text is a security problem. Password will be
> net use z: \\192.168.145.162\Backup /USER:Administrator 123456Aa.
Join File Share Persistently
Mounting or joining remote file shares will have only effect current sessions. If session is closed or system is restarted or connection is lost the share will not mounted automatically. This is the default behavior. We can also join or mount a remote file share persistently with the
> net use z: \\192.168.145.162\Backup /Persistent:Yes
Join File Share and Specify Drive Letter
Up to now we have not specified a local drive letter to the mounted or joined remote share. The default behavior is providing a drive letter in a row manner. We can specify the drive letter like
:Z like below.
> net use :w \\192.168.145.162\Backup
Make All Future Connections Persistent
The default behavior of the
net use command is making connections not persistent. If we want to make all future connection persistent without specifying persistent option explicitly we need to enable persistence globally like below.
> net use /Persistent:Yes
Join Printer Share
Printers also a remote resource which can be used by multiple computers like file shares. We can use
net use command in order to join a printer into local system. We just provide the printer IP address or host name.
> net use LPT1: \\192.168.1.10\prn
Disconnect From A File or Printer Share
If we want to remove, delete or disconnect from all ready connected share we can use
/delete option. We also need to specify the share letter we want to remove. In this example we will remote share named
:z like below.
> net use :z /delete
Disconnect and Close All Shares
We may need to removei close and disconnect all currently mounted shares. We will use
* with the
/delete like below.
> net use * /delete
There is a confirmation mechanism which will ask us that whether we want to continue removal of the remote shares.