skip to Main Content
Automate Network Share Mappings In Windows

Automate network share mappings in Windows

How to automate network share mappings in Windows

In our previous post, we explained how to map a network share in Windows manually by using the GUI (Graphical User Interface). Today we are going to show step by step, how to automate network share mappings in Windows by using the command line and saving it in scripts also known as batch files.

If you prefer to map your shares manually, you can read our previous post over here.

While the GUI can be more convenient in some cases, there are more efficient ways of performing a task once it becomes repetitive. Like in our example, when mapping a network share by using the GUI you have to:

  • Open the Explorer
  • Map the network drive
  • Select the drive letter
  • Type out the share path
  • Tick off the checkboxes
  • Enter network credentials

We could also accomplish this by compressing all of those steps into a single line of commands entered on the command line. The command that is being used to map network drives in Windows is net use.

Example:

Our share fsdrive resides on the s2016 server with the IP address of 192.168.4.38. The user administrator with the password Welcome.01 has permissions to access this share. Based on this scenario our syntax would look like this:

net use y: \\192.168.4.38\fsdrive /u:s2016\administrator Welcome.01
net use command breakdown

Ok, so now we know how to map a share from the command line but how to automate this process?
First, we’re going to save the command into a text file. Type notepad on your Windows search bar to open up the text editor.

open up your notepad

Type out or copy and paste the command we used before.
type out or past the command in notepad

Now we’re going to create a script also known as a batch file. Click on File and then on Save As.
save as in notepad

Specify a file name followed by a dot and the letters bat. Consider saving it to an easy to remember location like for example, the Desktop.
save as .bat

Select All Files from the Save as type: dropdown menu.
select all files in the save as a type - dropdown menu

Now the command is stored in our newly created batch file. But, we also want to run it every time we boot up our system or log on to it. The easiest way of doing this is to copy our batch file, then open up This PC and select the explorer address bar.
select and type the folder address in the explorer address bar

Navigate to the following folder: C:\programdata\Microsoft\Windows\Start Menu\Programs\Startup and paste it in here.

navigate to the startup folder

Click on Continue where Windows will ask you to provide for administrator permissions.
click on continue

The script will now run during every boot or when you log on to Windows.

Note: You could also leave the password out, but then Windows is going to ask you for your credentials every time the script runs.

batch file prompting for password
Thank you for your time reading our guide on how to Automate network share mappings in Windows. Please leave us a comment if you found it useful.

Until the next time – TechGuideReview.

TechGuideReview

TechGuideReview

Information Technology passionate. Founder of the TechGuideReview blog.

This Post Has 0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top