' ########################################################################
' Establishes map drives.
' Assign to OU Group Policy under USER CONFIG, WINDOWS SETTINGS, SCRIPTS, LOGON SCRIPT.
'
' This script will:
' (1) check if the drive is already connected and, if so, disconnect it.
' (2) map the drive.
'
' Arguments are as follows:
' MAPIT DRIVE-LETTER as string, PATH as string, USER as string, PASSWORD as string
' (1) Do not specify colon in drive letter.
' (2) Do not end path with a forward slash.
' (3) If user and password are not required to establish map, then specify a zero-length string as follows: ""
'
' Reference Microsoft info at:
' http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/wsmthmapnetworkdrive.asp
' ########################################################################
Dim objShell : Set objShell = CreateObject("Wscript.Shell")
objShell.Run "xcopy " & chr(34) & "\\climateworks.local\NETLOGON\Template\normal.dotm" & chr(34) & " " & chr(34) & "%USERPROFILE%\Application Data\Microsoft\Templates" & chr(34) & " /Y /I /Q"
' Create the Shell or environment for the commands:
Set WshShell = WScript.CreateObject("WScript.Shell")
' Define objects:
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set oDrives = WshNetwork.EnumNetworkDrives()
'Get Username to map to HOME drive
LPHSUser = WshNetwork.UserName
' ====================================
' DEFINE WHO TO CONTACT for pop-up messages:
' ====================================
strContactMessage = "If you require assistance, please contact itsupport@bando.com."
' ==================
' DEFINE DRIVES TO MAP:
' ==================
Mapit "W", "\\FS1\Shared", "", ""
Mapit "U", "\\FS1\Users\" & LPHSUser, "", ""
'TO MAP TO HOME DRIVE USE: Mapit "K", "\\aphrodite\users\" & LPHSUser, "", ""
'ALSO NAME HOME FOLDER TO CORRESPONDING USERNAME
' Your printers somewhere around here...
Set WshNetwork = CreateObject("WScript.Network")
WshNetwork.AddWindowsPrinterConnection "\\FS1\XeroxPhaser3500"
WshNetwork.AddWindowsPrinterConnection "\\Fs1\ColorXeroxPhaser8560"
WshNetwork.AddWindowsPrinterConnection "\\Fs1\Xerox_7328_MFP"
WshNetwork.AddWindowsPrinterConnection "\\Fs1\XeroxPhaser3600_FAR"
'WshNetwork.SetDefaultPrinter "\\FS1\XeroxPhaser3500"
' ========
' CLEAN UP:
' ========
Set WshShell = Nothing
Set WshNetwork = Nothing
Set oDrives = Nothing
' ##################################
' DO NOT MODIFY ANYTHING BELOW THIS POINT...
' unless you are familiar with the proper settings.
' ##################################
Sub Mapit(strLetter, strPath, strUser, strPass)
' Define the DriveLetter:
DriveLetter = strLetter & ":"
' Define the remote path:
RemotePath = strPath
' Pop-up Notices (set to False to disable notices, otherwise set to True):
bPopReminder = False
' Define known errors to trap:
Dim arrErrCode(1)
Dim arrErrDesc(1)
arrErrCode(0) = -2147023694
arrErrCode(1) = -2147024811
arrErrDesc(0) = "Unable to map drive " & DriveLetter & " to " & RemotePath _
& " due to a previously defined remembered map with the same letter." _
& vbCrLf & vbCrLf & "Please MANUALLY disconnect map drive " & DriveLetter _
& ", then Log Out and Log back in."
arrErrDesc(1) = "Unable to map drive " & DriveLetter & " to " & RemotePath _
& " since " & DriveLetter & ": was previously reserved by your computer." _
& vbCrLf & vbCrLf & "(Refer to Management, Shared Folders, Shares)"
' Define whether the map information should be removed from the current user's profile:
bForceRemoveFromProfile = True
bRemoveFromProfile = True
' Define whether the map information should be stored in the current user's profile:
bStoreInProfile = False
' Check if already connected:
AlreadyConnected = False
For i = 0 To oDrives.Count - 1 Step 2
If LCase(oDrives.Item(i)) = LCase(DriveLetter) Then AlreadyConnected = True
Next
' Attempt to map the drive. If already mapped, first attempt disconnect:
If AlreadyConnected = True then
WshNetwork.RemoveNetworkDrive DriveLetter, bForceRemoveFromProfile, bRemoveFromProfile
If Not strUser = "" Then
WshNetwork.MapNetworkDrive DriveLetter, RemotePath, bStoreInProfile, strUser, strPass
Else
WshNetwork.MapNetworkDrive DriveLetter, RemotePath, bStoreInProfile
End If
If bPopReminder Then WshShell.PopUp "Drive " & DriveLetter & " disconnected, then connected successfully to " & RemotePath
Else
On Error Resume Next
If Not strUser = "" Then
WshNetwork.MapNetworkDrive DriveLetter, RemotePath, bStoreInProfile, strUser, strPass
Else
WshNetwork.MapNetworkDrive DriveLetter, RemotePath, bStoreInProfile
End If
If Err.Number <> 0 Then
bKnownError = False
For I = LBound(arrErrCode) To UBound(arrErrCode)
If Err.Number = arrErrCode(I) Then
bKnownError = True
strPopMessage = arrErrDesc(I)
' Display the Disconnect Network Drives window:
If Err.Number = arrErrCode(0) Then
Set objWSH = Wscript.CreateObject("WScript.Shell")
objWSH.Run "rundll32.exe shell32.dll,SHHelpShortcuts_RunDLL Disconnect", 1, true
End If
Exit For
End If
Next
If Not bKnownError Then
strPopMessage = "Unable to map drive " & DriveLetter & " to " & RemotePath _
& " due to reason stated below."
End If
' Display warning message:
'strPopMessage = "WARNING!! WARNING!! WARNING!! WARNING!!" _
' & vbCrLf & vbCrLf & strPopMessage _
' & vbCrLf & vbCrLf & Err.Description & " (error " & Err.Number & ")" _
' & vbCrLf & vbCrLf & strContactMessage
'WshShell.PopUp strPopMessage
Else
If bPopReminder Then WshShell.PopUp "Drive " & DriveLetter & " connected successfully to " & RemotePath
End If
End If
' Release resources:
Set objWSH = Nothing
' Slight pause to ensure each pass has time to commit:
wscript.sleep 200
End Sub
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
by: plimpiasPosted on 2009-07-27 at 17:31:41ID: 24957048
HI if your trying to run this at logon but these users have to log in first it will not work. Unless you use the vpn before logon.
/products/ sw/secursw /ps2308/ pr oducts_tec h_note0918 6a00807955 bc.shtml
i don't know which VPN clinet you are using but i find the SSL works the best
http://www.cisco.com/en/US
Once you VPN in, after you login it will run at logon. I would convert the policies over to 2008 so that they can be cached on the laptop instead of having to run each time.