Preparing for Java and Spring Boot Interview?

Join my Newsletter, its FREE

Wednesday, May 17, 2023

How to Map a Network Drive to Windows Machine - net use Command Example

Mapping network drive in Windows 10 or other versions of Windows operating system e.g. Windows 7  or Windows 8 is much easier and faster by using the command line than by doing it on Windows Explorer. If you have been working in a Windows environment with a bunch of Windows Server 2016 or 2012  servers and your job requires frequent access, copy or paste from the local machine to those remote machines then mapping them as a network drive is the best option. 

You can use a mapped network drive as any other folder which makes the job of copy paste very simple. Though windows provide multiple ways to map a network drive, I prefer to use the command line i.e. "net use" command to map my windows network drives.

This works in Windows 10 and should work in other versions of the Windows operating system as well e.g. Windows 7 or Windows Server 2016 without any fuss.

It's way faster than accessing every single node on a network to reach desired fast and In order to use this, you just need to change of network drive. 

In our last post on Windows operating system, we have seen How to find IP addresses from a hostname, and in this article, we will see how to map remote hosts as a network drive in Windows 10. Anyway enough talking,

 let's see the command to map a network drive in windows:

NET USE command to map a network drive in Windows

Windows command to map network drive is "net use" and we will use option * which automatically assigns a name of drive e.g. X drive, Y drive, Z drive. 

Now let's see an example of mapping D:\ drive of remote host as windows mapped a drive in your desktop:

C:\Documents and Settings\supportUser>net use * \\\D$ * /u:domain\username
Type the password for \\\D$:
Drive S: is now connected to \\\D$.
The command was completed successfully.

Now this network folder will be visible as S:\ drive in your My Computer. 

1. Command to show windows mapped network drive

Here is a command to show all network drive which is mapped, we will use the same net use command without any option to see all drives as shown below:

C:\Documents and Settings\supportUser>net use
New connections will be remembered.

Status       Local     Remote                    Network
OK           A:        \\hostname1\drive1       Microsoft Windows Network
OK           I:        \\hostname1\drive1       Microsoft Windows Network
Disconnected N:        \\hostname3\drive3       Microsoft Windows Network
Unavailable  Z:        \\hostname3\d$           Microsoft Windows Network
The command completed successfully.

2. Command to disconnect mapped network drive in Windows 10

You can use the same command net use to even disconnect mapped network drive, just pass /d argument to net use command for disconnecting mapped network drive as shown below :

C:\Documents and Settings\supportuser>net use /d z:
z: was deleted successfully.

So far, we have seen how to use the "net use" command to configure and disconnect a network drive on a Windows laptop. Btw, if you want to do it Windows way e.g. by using GUI interface then you can also do so starting from Windows 7 as shown below:

How to Map a Network Drive to Windows Machine - net use Command Example

That’s all on windows command to map remote host as a network drive in Windows 10 and Windows Server 2016. As I said using the command line to map network drive is much faster than using windows explorer, it prevents your computer from being hung during the mapping process.  Btw, if you are interested in more scripting work on Windows like Linux, I encourage you to learn Powershell, which gives you the power of Linux in Windows. 

Since net use is one of the basic commands this trick should also work on other versions of the Windows operating system e.g. Windows 11 or Windows Server 2019. 
Let us know if you find any other faster way of mapping drives in Windows 10 or other Windows versions. 

Other Technical Resources you may like
5 Free Course to Learn Linux Online
10 Free Courses to Learn Docker Online
10 Examples of lsof command in Linux

Thanks for reading this article so far. If you like this tip then please share it with your friends and colleagues. If you have any questions or feedback then please drop a note.

1 comment :

Anonymous said...

It appears that passing credentials through "net use" does not influence Explorer in Windows 7 any more. Even after successful "net use" on ipc$ or particular x$ drive Explorer asks for credentials when entering the address for the same machine.

Do you have any idea how to find a solution to that problem?

Post a Comment