Windows Scripting - Network Admin

February 9, 2009 at 09:55:48
Specs: Windows XP
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


See More: Windows Scripting - Network Admin

Report •


#1
February 10, 2009 at 15:30:33
ping 1.0.0.0 -n 1 -w 5000
This is not a VBScript command. It is a command script. VBScript doesn't know what to do with this, so the script won't run. Replace it with:
WScript.Sleep 5000

If you're not getting an error message, then I'd assume you were running the script in Batch mode. A mode which suppresses all errors.


Report •
Related Solutions


Ask Question