Nov 16, 2010

Mapping Network Drives on a Stick

Summary

This short tutorial will get network drives to map quickly.

The Tutorial

Start by copying this base script into TextPad (or your text editor of choice):
@echo off

cls
echo == Initiating system instance variables...
echo. -- Setting the variables...
set Drives=0
set UserName=
set /P UserName=Username: %=%

echo.
echo. -- Running

:: Here you will need to set each of the drives you want to get setup by this script
:: Edit each SUBDOMAIN, DOMAIN, FOLDER, and the drive letter to your needs.
:: /USER:%UserName% should remain as it is

Set /A Drives+=1
echo. Adding drive %Drives%
net use s: \\SUBDOMAIN1.DOMAIN1.com\FOLDER2 /USER:%UserName%

Set /A Drives+=1
echo. Adding drive %Drives%
net use t: \\SUBDOMAIN2.DOMAIN2.com\FOLDER2 /USER:%UserName%

:: Repeat the above three lines for as many map drives as needed.

echo. -- Cleaning up...
set UserName=
set Drives=
echo. ++ Done.
echo.
pause
Edit the "net use" lines to the folder that needs to be mapped. The drive letter, domain, and folder needs set. "/USER %UserName%" doesn't need edited.

The set of three lines "Set, echo, net" may be repeated for as many files as you need.

Credit Where Credit is Due

Mapping drive letters by garethcummings, getting input from a user by Secret_Doom, and counter incrementing by zrm0008 were all sources used to get this script working.

No comments: