Powershell

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

The “net use” is a Command Prompt specific command used to connect or disconnect a computer from shared resources. Moreover, it helps to display information about the computer connections. To get the list of network connections, it can be used in the absence of parameters. It has several other parameters that can help get the connection information, connect to the servers, etc.

This blog will elaborate on the “net use” cmdlet of Command Prompt.

How do Connect to Network Drives on the Command Line Using the Cmdlet “net use”?

As described above, the stated command is responsible for connecting or disconnecting computers from shared resources.

Example 1: Use the “net use” Cmdlet to Map the Shared Directory on Server a Drive Letters

This illustration will assign a drive letter to a shared directory available on the server:

net use e: \\document\letters

In the above code, specify the “net use” cmdlet and then assign the shared directory “letters” to the “e” drive.

Example 2: Connect the User Identifier to the Server

To connect the user identifier with the shared directory, use the following demonstration:

net use f:\\server1\shared /user:Accounts\User12

Following the above code:

  • First, specify the “net use” cmdlet.
  • Then, add the server-mapped shared directory.
  • After that, enter the user account along with the identifier value.

Example 3: Use the “net use” Cmdlet to Disconnect From the Connected Directory

To disconnect the server from the connected directory, the below-stated command can be used::

net use f: \\finance\public /delete

In the above code snippet:

  • First, use the “net use” cmdlet.
  • After that, specify the network-mapped shared directory along with the “/delete” value to disconnect the directory.

Example 4: Use the “net use” Cmdlet to Connect With the Resource Memos

This example will connect the memos with the network drive. To do so, simply specify the “\memos” value after the network-mapped shared directory:

net use g: "\\finance 2" \memos

Example 5: Use the “net use” Cmdlet to Restore the Current Connections at Each Logon

To restore the current connection at each logon, execute the provided command::

net use /persistent:yes

According to the stated code above:

  • Initially, specify the “net use” cmdlet.
  • Then, add the value “/persistent:yes” to restore the connections at logon.

That was all about connecting drives to the network using the “net use” command.

Conclusion

The “net use” is a CMD cmdlet used to connect or disconnect the computer from network resources. Moreover, it maps the drives to a network server. This post illustrated the methods for connecting the network drive with the server.

About the author

Muhammad Farhan

I am a Computer Science graduate and now a technical writer who loves to provide the easiest solutions to the most difficult problems related to Windows, Linux, and Web designing. My love for Computer Science emerges every day because of its ease in our everyday life.