The script source:
' Author: Chris Stone
' Date: 29 MAY 2009 Version: 1.3
' Purpose: Map network drives
On Error Resume Next
Set objNet = CreateObject("WScript.Network")
Public Sub CheckAndMapNetDrive(Letter, Path, Persist)
'Check if drive letter is already used
Set colNetDrives = objNet.EnumNetworkDrives
For i = 0 To colNetDrives.Count - 1 Step 2
If colNetDrives.Item(i) = Letter Then
'Drive Letter Exists, Test if it's the same Path
If colNetDrives.Item(i+1) = Path Then
'It's the same, no new mapping necessary.
Exit Sub
Else
'It's different, remove old.
objNet.RemoveNetworkDrive colNetDrives.Item(i)
End If
End If
Next
'Drive does not exist now, never did or removed.
objNet.MapNetworkDrive Letter, Path, Persist
End Sub
' Edit the following to fit your environment!
' CheckAndMapNetDrive [Drive_Letter], [Net_Path], [Bool_Persist]
CheckAndMapNetDrive "R:", "\\server1\share1", True
CheckAndMapNetDrive "S:", "\\server1\homes\" & objNet.UserName, True
CheckAndMapNetDrive "T:", "http://webdav.example.com", False
As stated above, edit this script to map the drives you need, then save a copy in the \\domain.com\netlogon share (it can be placed elsewhere, but this is traditionally the standard location for login scripts). Remember to properly document how and why you are mapping network drives. Test the script to be sure it is working as expected.
After the file is edited, saved, and tested; open Group Policy Management. Create or Edit a GPO for the Domain or OU as is appropriate for your environment. Find Logon under User Configuration > Policies > Windows Settings > Scripts. Open Logon's properties, click the Add button and enter the path where you placed the script; no script parameters are necessary unless you added parameter handling ability to the script. OK your way back through the screens and close it out.
Your clients will have to refresh their policy before this will take effect. That usually happens before login and every ~30 minutes (but these are the default settings); run
This script works on Windows 2000 and newer Windows OSes, both 32-bit and 64-bit.