Windows Net Use Command Tutorial

Windows operating systems provide the net use command in order to use network resources and shares easily from the command line. The net use command is provided with Windows XP, Windows Vista, Windows 7, Windows 8, Windows 10, Windows Server 2003, Windows Server 2008, Windows Server 2012, Windows Server 2016, and Windows Server 2019. The net use command is used to create persistent net connections.

net use Command Syntax

In general, the net use command uses the following syntax where the DEVICE_NAME, SHARE_NAME, and OPTION can be provided.

  • DEVICE_NAME is the name to connect to the resource or specify the device to be disconnected. The device name can be a drive letter like D: , Z: or printer name like LPT1: .
  • SHARE_NAME is the network share that will connect to the local system.
  • OPTION is used to set some attributes for the net use command.

net use Parameters

The net use command provides different parameters to save credentials, delete connections, specify users, etc.

/user:USERSet user name as USER
/savecredSave and store credentials for later use.
/delete Delete or disconnect the specified connections.
/persistentMake connections persistent or disable persistency.
/homeConnect a user to the home directory
net help usePrint help information

Print Help Information

The /? option or /help can be used to print detailed help information about the net use command.

C:\>net use /?
The syntax of this command is:

[devicename | *] [\\computername\sharename[\volume] [password | *]]
        [/USER:[dotted domain name\]username]
        [/USER:[username@dotted domain name]
        [[/DELETE] | [/PERSISTENT:{YES | NO}]]

NET USE {devicename | *} [password | *] /HOME

net use /help

Connect/Map Network Share

The net use command is mainly used to connect remote networks shared with the local drives by using drive letters. In the following example, we will connect the remote share named \\srv\media to the local drive or letter Z: .

> net use Z: \\srv\media

Alternatively, we do not specify the local drive name or letter and provide the * asterisk which will be used to select a free drive letter automatically. If you do not want to search for a free drive letter this will be very useful but keep in mind that every time the remote share is mounted the drive letter may change.

> net use * \\srv\media

List All Shared Resources and Display Information About Connection

After a remote source or share is connected to the locally we may need to print or display information about this connection. The net use command without any parameter will list currently active connections and provide information about these connections.

> net use
List All Shared Resources and Display Information About Connection

Connect with Provided User/Password

By default, the net use command will use the current session username and will ask for a password if it is required. We can also provide the different users for the net use command with the /user parameter and provide the username. In the following example, we will

> net use e: \\srv\media /user:ismail

If the user is a domain user you should also provide the domain name with the username. We will just provide the domain name like regular user login. In the following example, the domain name is windowstect .

> net use e: \\srv\media /user:windowstect\ismail

Save Credentials

By default, the user credentials are not saved. The user credential is the username and password. We can save the user credentials in order to prevent the username and password again and again for every map. We will use the /savecred option with the net use command.

> net use e: \\srv\media /user:windowstect\ismail /savecred

Make Current Connections Persistent

By default, the connections are not persistent. This means in a reboot the connection will be lost and not created again in the next boot. But you can use the /persistent parameter with the yes value in order to make current connections persistent.

> net use /persistent:yes

You can also make a connection persistent during the connection phase with the /persistent:yes parameter like below.

> net use e: \\srv\media /user:windowstect\ismail /savecred /persistent:yes

Disconnect A Network Share

The net use connections can be disconnected manually by using the /delete option. At the same time, there may a more than one network share or connection and we should specify the connection with the drive letter and remote resource name.

> net use e: \\srv\media /delete

Leave a Comment