A Batch Script to Map Folders

Map Local and Network Folders in Microsoft

In an enterprise environment, it is not uncommon for users to get their network folders disconnected on a regular basis. Problems can arise from VPN issues, power fluctuations, or other concerns. To help user’s get their connections back quickly you can make a batch script and save it on their desktop or in their startup folder. Rather than calling the service desk for help, user’s can just double click the file and restore their network folders.

Let’s create a script called ‘mapdrivces.bat’ using notepad. Add information to the headers. Anything with REM or :: will not be executed.

Use ‘echo off’, at the top of the script. This tells the script to not display the commands or results to the screen, as they are executed. Use ‘echo.’ to print a blank line, and just plain echo to print any data to a screen.

Comment your code using descriptors and map the folder paths. The command to map network files is ‘net use’. Be sure to put quotes around the file path if there is a space somewhere in the path.

Finally, let’s create a short delay and exit the program. We can add the command ‘pause’ and it will hold the command prompt open until a key is struck or use ‘ping’ and it will wait three seconds and exit automatically.

Now, open File Explorer and see your newly mapped folders.

Related Posts