Computing.Net > Forums > Programming > Windows Scripting - Network Admin

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Windows Scripting - Network Admin

Reply to Message Icon

Name: ksoliz
Date: February 9, 2009 at 09:55:48 Pacific
OS: Windows XP
Subcategory: Batch
Comment:

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



Sponsored Link
Ads by Google

Response Number 1
Name: Razor2.3
Date: February 10, 2009 at 15:30:33 Pacific
Reply:

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.


0
Reply to Message Icon

Related Posts

See More


Installing SMS2003 with a... VB If Statements



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Windows Scripting - Network Admin

windows scripting/coding admin ? www.computing.net/answers/programming/windows-scriptingcoding-admin-/13693.html

I need a script. Kinda Urgent. www.computing.net/answers/programming/i-need-a-script-kinda-urgent/7448.html

Windows Scripting problem www.computing.net/answers/programming/windows-scripting-problem/13641.html