How to Connect to Network Drives on the Command Line with Net Use

choubertsprojects

VPN offers!

1. NordVPN

2. Surfshark

3. ExpressVPN

If you’re trying to connect a network drive, but the command line instructions seem too complicated for your taste- don’t worry! There is an easier way. Using whatisconnet.exe and netsh wlan show interfaces will reveal how to use Win + R commands or PowerShell with less typing

The “net use command map drive” is a command-line tool that allows users to map network drives. This article will show you how to use the net use command in Windows and Linux.

How to Connect to Network Drives on the Command Line with Net Use

The Windows net command is undoubtedly one of the most common commands in a senior Windows administrator’s arsenal. This command provides a number of useful features. This tutorial will teach you how to utilize the internet.

The net use command is a historical command for creating, removing, and managing SMB Windows mapped connections and disks that is still fully functioning.

In this lesson, we’ll look at the net use command and see what it can do as well as how to utilize it.

Prerequisites

If you want to follow along with any of the examples in this tutorial, you’ll need at least:

  • In an Active Directory domain, a Windows client PC (any version will work). Windows 10 will be used in this lesson.

In non-domain contexts, the net use command will operate. If you don’t, you’ll have to provide a username and password to access the remote file share.

  • A user account with read rights on the file share and NTFS read permissions on the folder to which the share points

How to Begin Using the Internet

You may use the net use command to interact with files on network file shares. It does this by using a variety of settings and switches, as illustrated below.

Finding net usage parameters with the aid of the internetFinding net usage parameters with the aid of the internet

The net use command allows you to examine device connections, establish new ones, and delete old ones. Throughout this course, you’ll learn about each parameter and discover how it applies to different scenarios.

The endpoints it interacts with are referred to as ‘connections’ rather than ‘drives’ in most of the literature you’ll find on the internet. This command can connect to printers and other devices, but for the sake of this article, you’ll be focusing on remote file shares.

Developing Remote Relationships

One of the most typical uses of the net use command is to create new connections. This command enables you to connect to distant file shares and copy, remove, and delete files as if the folder you’re connected to were local.

With net usage, you have two choices for creating a new remote file sharing connection. You can either build a “deviceless” connection, which is essentially a file sharing connection without a drive letter, or a mapped drive, according to Microsoft.

Using Logged-In Credentials to Map Network Drives

One of the most popular applications of the net use command is to map network drives. This command, similar to File Explorer, enables you to map a network drive from the command line.

Assuming you’re using a Windows 10 PC in a domain with a Windows server hosting a file share, follow these steps:

1. Log in as an administrator to a command prompt or PowerShell console.

How to Run PowerShell as an Administrator is a related topic.

2. Let’s map the drive letter F: to the C$ file share on the DEVSRV server. To do so, provide the drive letter to which you want to map the network drive, then the UNC path to the remote file share.

If it isn’t currently in use, you may map the network drive to any letter.

If the file share has spaces, always include it in quotes, such as DEVSRV”My File Share.”

The Drive's MapThe Drive’s Map

3. Run net usage with no arguments to verify that Windows properly mapped the device.

Use the InternetUse the Internet

4. When you Open the File Explorer application., you’ll discover a new network location.

Open the File Explorer application.Open the File Explorer application.

You may also use an asterisk (*) for the drive letter if you don’t care which device (drive letter) to map the disk to. This instructs Windows to look for the next available drive letter.

For the Drive Letter, use an asterisk.For the Drive Letter, use an asterisk.

Using Alternative Credentials to Map Network Drives

If you followed the instructions above and mapped a network disk, you did so as the logged in user. But what if you need to access the remote file share with a different set of credentials?

Mapping a network disk as a non-logged-in user account is almost identical to mapping a logged-in user account. The only difference is that a few extra parameters are used.

Open a command prompt or PowerShell terminal as an administrator to map a network disk using different credentials.

Use the Internet providing:

  • The drive letter that should be mapped to
  • The file share’s UNC path.
  • The username to use for authentication (/u)
  • The username and password

In the below example, Windows will map the F: drive to the \DEVSRVc$ file share authenticating as the test_user account in the domain domain using The username and password of passwordhere.

/u:domaintest user passwordhere net use f: DEVSRVc$

Remove the domain from the username option, e.g. /u:test user, to provide a local user account on the remote machine.

Use the /savecred parameter to save the credentials to prevent being prompted The username and password later.

Make “device-agnostic” connections (No Drive Letter)

You may need to access a remote file share but don’t want to assign it a drive letter. Simply delete the drive letter in such situation.

Let’s create a file share connection without a drive letter known as a “deviceless” connection. Assuming you’re using a Windows 10 PC in a domain with a Windows server hosting a file share, follow these steps:

1. Log in as an administrator to a command prompt or PowerShell console.

How to Run PowerShell as an Administrator is a related topic.

2. Create a “deviceless” connection by entering the UNC path to the remote file share, as well as a username and password to login.

DEVSRVc$ /u:domaintest user passwordhere DEVSRVc$ /u:domaintest user passwordhere DEVSRVc$ /u:domain

If your client computer and the distant Windows server are both members of an Active Directory domain, and you’re signed into your client computer using a domain user account, you shouldn’t utilize net usage. These materials are currently available to you without any further efforts. However, it comes in useful when you need to login with a different user account.

The connection has been established, but there is no evidence of it in File Explorer. This is a “device-free” connection.

There is No Need for a Device to ConnectThere is No Need for a Device to Connect

3. Verify that the connection was established by executing net use without any arguments. As you can see in the screenshot below, Windows recognizes the existence of a connection.

Verify the RelationshipVerify the Relationship

Using the alternative user account credentials, you may now browse and operate with the file share as if it were local to you.

Navigate the file share and operate with it.Navigate the file share and operate with it.

Persistent Relationships

When you make new connections, Windows may maintain them after a reboot, which is referred to as persistence. The /persistent argument of the net use command specifies whether or not a connection will continue after a reboot.

To keep a connection alive, use the /persistent argument with each attempt to make a new connection, such as:

DEVSRVc$ /persistent:yes /net use

By default, mapped disks are not persistent.

The persistence setting of the last formed connection will be remembered by Windows. If you set /persistent to yes for a connection, it will be permanent for all future connections until you specifically set /persistent to no. Use net use /persistent:yes to guarantee that all connections in the current session are permanent.

Parameters for Advanced Connections

To make a connection, you’ll usually simply need the settings mentioned before. However, there may be times when you’ll need to execute some complicated connection activities.

Using Write Through to Map Drives (Forced Unit Access)

The /writethrough option was added in Windows 10 build 1809, and it allows you to designate a drive that bypasses all OS caches and forces I/Os to disk.

Boosting Security

Through a feature called UNC Hardened Access, the net use command also supports two additional arguments that strengthen security: /reguireintegrity and /requireprivacy. This feature “tags” information on these shares so that MUPs and UNC providers are aware of any extra security requirements.

The /requireintegrity argument adds extra integrity tests to prevent manipulation.

The /requireprivacy argument tells net usage to encrypt the file sharing transmission so that other parties can’t view any sensitive information.

Getting Rid of Network Connections

Finally, if you’ve created some connections and need to erase them, the /delete argument comes in handy. Provide the /delete argument together with the UNC path of the network share to delete a non-persistent connection, as illustrated below.

/delete /net use /devsrvc$

Getting Rid of Network ConnectionsGetting Rid of Network Connections

Provide the drive letter and the mapped drive to delete a mapped drive.

f:devsrvc$ /delete net use

Conclusion

You should now have a decent understanding of just about everything the net use command can perform. This ancient yet useful tool is still in use today and might assist you in mapping network drives in Windows.

How will you make advantage of the internet?

The “net use /delete drive” is a command-line tool that allows users to connect to network drives on the computer. This article will help you learn how to do it.

Frequently Asked Questions

Related Tags

  • net use command to map drive with username and password
  • net use delete
  • access mapped drive from command prompt
  • net use command to connect to remote computer
  • net use command with username and password