Mapping network drives to users in SBS

More often than not it's necessary to map network drives for users at logon in the Small Business Server (SBS) 2000 and 2003. One method commonly used is through the use of batch files, however, there are other ways to accomplish this task.

The default SBS login script is located at:
C:\WINDOWS\SYSVOL\sysvol\[domainname].local\scripts\SBS_LOGIN_SCRIPT.bat
Please substitute [domainname] for the name of your domain. My domain name is called '2Company' so my path to the login script looks like:
C:\WINDOWS\SYSVOL\sysvol\2company.local\scripts\SBS_LOGIN_SCRIPT.bat
This folder is shared as 'NETLOGON', therefore, a quicker method of accessing the 'scripts' folder is via \\[machinename]\\NETLOGON, where [machinename] corresponds to the name of your domain controller.

The contents of SBS_LOGIN_SCRIPT.bat will look something like this (let's assume my domain controller is called PERCY):
\\PERCY\Clients\Setup\setup.exe /s PERCY
Note: before modifying this file take a copy of it!

Add the following line to the batch file
\\PERCY\netlogon\MapDrives.bat
So your .bat file will now look something like this (I've added comments to it using the REM statement):
REM Default SBS Login Script
\\PERCY\Clients\Setup\setup.exe /s PERCY
REM MapDrives Script
\\PERCY\netlogon\MapDrives.bat
I have also created a MapDrives.bat file with the following lines and placed in the 'scripts' folder:
Rem Batch File to map drives at login
NET USE z: \\PERCY\Company
NET USE Y: \\PERCY\Software
NET USE X: \\PERCY\Accounts
A few comments about the above:
  1. You can call different login scripts for different users on the domain by calling a login script using \\PERCY\netlogon\%username%.bat instead of \\PERCY\netlogon\MapDrives.bat
  2. It is recommended to add each line as a call statement in the default login script, rather than just a line. There is potential with more than 2 lines in the default login script for them not to execute. If you use call you force the focus back to the default logon script after exectution of your new line (see revamped login script below).
  3. If for some reason there is a previously mapped drive the 'login mapping' as it is will fail. You will need to add the '/DELETE' statement at the end of the 'NET USE' command.
SBS_LOGIN_SCRIPT.bat
REM Default SBS Login Script
Call \\PERCY\Clients\Setup\setup.exe /s PERCY
REM MapDrives Script
Call \\PERCY\netlogon\MapDrives.bat
REM %username% script
Call \\PERCY\netlogon\%username%.bat

:End
MapDrives.bat
Rem Batch File to map drives at login
NET USE z: \\PERCY\Company
NET USE Y: \\PERCY\Software
NET USE X: \\PERCY\Accounts
Sample %username%.bat file, e.g. percyuser.bat
Rem Batch File to map drives at login for an arbitrary user
NET USE z: \\PERCY\Users\percy.user

Published Tuesday, April 18, 2006