I have a script I created by extrapolating from many sources. The drives map fine however my "pauses" aren't working and allowing me to view any error message if any. I have tried the wscript.echo as well as the msgbox. Neither worked. Are there certain permission a user must have to have this work? Also at one point the printer mappings had worked and now nothing. The script:
Option Explicit
'Declare variables
Dim objNetwork, objUser, strUser, strAdsPath, strDomain, WshShell, strScriptPath
' Call script to disconnect all mapped drives
Set WshShell = CreateObject("WScript.Shell")
strScriptPath = "logoff.vbs"
WshShell.Run(strScriptPath)
ping 1.0.0.0 -n 1 -w 5000
'Obtain user info from ADS, set variable value
Set objNetwork = CreateObject("WScript.Network")
strDomain = objNetwork.userDomain
strUser = objNetwork.UserName
strAdsPath = strDomain & "/" & strUser
Set objUser = GetObject("LDAP://" & strUser)
MsgBox("ldap info:" & objuser)
objNetwork.MapNetworkDrive "H:", "\\SERVER\" & strUser
objNetwork.MapNetworkDrive "Q:", "\\SERVER\Data"
objNetwork.MapNetworkDrive "I:", "\\SERVER\Common"
For Each strGroup in objUser.memberOf
Set objGroup = GetObject("LDAP://" & strGroup)
MsgBox("group info:" & objGroup)
' Section which determines user group and maps respective drives and printers
If objGroup.CN = "SM_Corporate" Then
objNetwork.MapNetworkDrive "J:", "\\SERVER\Corporate"
objNetwork.AddWindowsPrinterConnection "\\SERVER\PRINTERNAME"
objNetwork.SetDefaultPrinter "\\SERVER\PRINTERNAME"
ping 1.0.0.0 -n 1 -w 5000
ElseIf objGroup.CN = "SM_Accounting" Then
objNetwork.MapNetworkDrive "K:", "\\SERVER\Accounting"
objNetwork.AddWindowsPrinterConnection "\\SERVER\PRINTERNAME"
objNetwork.SetDefaultPrinter "\\SERVER\PRINTERNAME"
ping 1.0.0.0 -n 1 -w 5000
End If
Next
ping 1.0.0.0 -n 1 -w 5000
WScript.Quit
|