Mapping Network Drives at Multiple Locations

Background

Network drives allow multiple users on the same network to have acccess to the shared folders/files. However, if you have two different sets of network drives (at work and at home, for example), it can be a hassle to manually map drives when your computer 'resumes' on the new network.

For example, if I'm at work, all my network drives are available. When I go home and connect to the local network, my work network drives disappear (that's fine, they're not available anyway) but my home network drives don't automatically map. The same is true when going from 'home' back to 'work'.

Manually mapping a network drive isn't difficult, but if you have to map multiple drives, multiple times a day, it's a hassle.

Solution

To make mapping easier, I designed a vbscript file that can map any number of network drives. The script file accepts one parameter at the command line - the name of the text (.txt) file containing the drive mappings you want.

With this in place, I can execute the command MapNetworkDrives.vbs drives-work.txt or MapNetworkDrives.vbs drives-home.txt to re-map my home or work drives, respectively. These commands can be easily saved as a shortcut (double-click the shortcut to map your drives) or built into an AutoHotKey script to detect your network and intelligently choose which drives to map.

Getting Started

To make this work, you need at least two files.

MapNetworkDrives.vbs is the script file that does the processing and mapping.

drives-work-sample.txt is an example of a file containing mappings. This file can be named anything you prefer; what's important is the format and contents of the file. The following note (also available inside MapNetworkDrives.vbs) explains that format:

This script maps network drives, based on an argument passed at the command line
The text file passed as argument 0 needs to be plain text, with a drive to map on
each line. The lines need to be pipe-separated (|), in the format:
DriveLetter | UNC Path to map | Name to be assigned to mapping
Optionally, a username and password can be provided to the script for each mapping:
DriveLetter | UNC Path to map | Name to be assigned to mapping | username | password

You'll want a separate version of this file for each network location at which you want to map drives.

To get the code, and read how to set up a Windows Desktop Shortcut to automate mapping your drives, click through for page two.

Tags: 

2016-11-14, 12:11 pm