How To Create A Windows Batch File To Map Multiple Drives At Once


Mapping a drive to a share on a remote computer can be a big time saver when you need to access files and folders remotely. Using Windows Explorer, you can easily map the drive to the share on a remote computer when needed.

But what if you need to map multiple drives at once, or you want to always map the drive when you logon to your computer?

The best solution is to create a batch file that you can click on, when you need to map the drives, or copy it to your Windows user account Startup folder so the drives are mapped automatically during logon.




To map drives using a batch file, we'll need to use the net use command. At it's simplest form, the command looks like this:

net use [devicename | *] [\\computername\sharename


devicename = the dive letter for the map drive

computername = is the computeer wher the share exists

sharename = is the name of the share

So to create a batch file that will map a drive to different computers that are sharing folders, we'll use the following commands:

net use W: \\computer1\MP3 

net use X: \\computer2\Photos

Note: you can assign any drive letter you want, as long as it is not in use by your computer (for example A or C drives).


What About Authentication?

Using the commands above to map drives, assumes that the account you are logged on as, exists on the remote computer where the shared folder is located, or if you are at work, is part of a Windows Domain.

If you need to authenticate when mapping the drive, we'll need to use an account that exists on the remote computer or in a Windows Domain, and add it onto the net use command as shown below:

net use [devicename | *] [\\computername\sharename password  /USER:username

Therefore the command will look like this when used in a batch file:

net use W: \\computer1\MP3 mypassword /USER:mary

net use X: \\computer2\Photos mypassword /USER:bob

If an error occurs (unknown user name), you will need to use the /USER switch with the domainname option as follows:

net use W: \\computer1\MP3 mypassword /USER:mydomain\mary

If the remote computer is not part of a Domain, and is part of a Workgroup, then substitute the Domain for the name of the remote computer (where the user account resides).

net use W: \\computer1\MP3 mypassword /USER:computer1\mary


Creating The Batch File

Ok, now that we know how to use the net use command, let's create the batch file.

  • First, open up Notepad or your favorite text editor.
  • Next, copy the commands as shown below and paste them into the file. Don't forget to modify the net use command with the drive letter you want to use, the name of the Computer and share you want to map a drive to, and password and account name (if needed).

ECHO Begin Mapping Drives
net use W: \\computer1\MP3 mypassword /USER:mary 
net use X: \\computer2\Photos myrealpassword /USER:bob 


  • Then save the file with any name and a .bat extension (make sure it's NOT saved using .txt as the file type extension), to a location where you can easily access it (such as your Desktop).
  • When you need to map the drive(s), just double click on it.


A Word About Security

Now, realize when using the net use command and hard coding passwords, make sure you understand that you are at risk if anyone gains access to the batch file. You don't want to create the batch file at work and save it to a File Server.

Use common sense, and don't be careless.

Read 138 times
Dylan Austin


Whenever I have a problem, I sing. Then I realize my voice is worse than my problem.

We use cookies to improve our website. By continuing to use this website, you are giving consent to cookies being used. More details…