Prev: WMI
Next: how to call vbe from wsf ?
From: Mandy on 20 Jul 2006 16:27 I'm getting runtime error 800A0035 when I run the following code. The labs.csv file is located in the same folder (NETLOGON folder) as the script and it still can't find it. any suggestions? '******************************************************** '*Title: Mapping Group Drive and Printer * '*Author: Mandy Dunn & Rob Kinney * '*Date: October 3, 2005 * '*Modified: October 3, 2005 * '******************************************************** '************************************************************************************************* ' Declare variables '************************************************************************************************* Dim WshSysInfo, WshUser, WshComputer, WshGroup, WshNet Dim WshShell Dim fso, MyFile, lineParts Dim strIpAddr, strMacAddr, strComputer, objWMIService Dim ipFound Dim SRCDATAFILE '************************************************************************************************* ' Create system connections for data extraction from host (IP, username, etc.) '************************************************************************************************* Set WshNetwork = WScript.CreateObject ("WScript.Network") Set WshSysInfo = Createobject("ADSystemInfo") Set WshUser = Getobject("LDAP://" & WshSysInfo.UserName) '************************************************************************************************* ' Test to see if computer is a member of "facstf Computers" or "student Computers" and ' map drives, printers accordingly '************************************************************************************************* Set WshGroup = GetObject("LDAP://CN=facstf Computers,OU=facstf,dc=ad,dc=cob,dc=ohio-state,dc=edu") If WshGroup.IsMember("LDAP://" & WshSysInfo.ComputerName) Then '************************************************************************************************* ' Force a grou policy update '************************************************************************************************* Set WshShell = CreateObject ("Wscript.Shell") WshShell.Run("%systemroot%\system32\gpupdate /force") Set WshShell = Nothing '************************************************************************************************* ' Map appropriate global network drives (H: is specific to user) '************************************************************************************************* WshNetwork.MapNetworkDrive "G:", "\\facstf\group$" WshNetwork.MapNetworkDrive "H:", "\\cobcore2.ad.cob.ohio-state.edu\" & WshNetwork.UserName & "$" '************************************************************************************************* ' Name global network drives (short strings for ease of understanding) '************************************************************************************************* Set WshShell = CreateObject("Shell.Application") WshShell.NameSpace("G:").Self.Name = "GROUP" WshShell.NameSpace("H:").Self.Name = "HOME" Else Set WshGroup = GetObject("LDAP://CN=student Computers,OU=groups,OU=student,dc=ad,dc=cob,dc=ohio-state,dc=edu") If WshGroup.IsMember("LDAP://" & WshSysInfo.ComputerName) Then '************************************************************************************************* ' This section will read in the labs.csv file and compare the IP of the machine to the file to set ' lab and machine specifics such as printers and default printer '************************************************************************************************* SRCDATAFILE = "\\WINDOWS\sysvol\sysvol\ad.cob.ohio-state.edu\scripts\labs.csv" ' the csv file format = (ip,lab,printer group) strComputer = "." ipFound = false '************************************************************************************************* ' Force a grou policy update '************************************************************************************************* Set WshShell = CreateObject ("Wscript.Shell") WshShell.Run("%systemroot%\system32\gpupdate /force") Set WshShell = Nothing '************************************************************************************************* ' Map appropriate global network drives (H: is specific to user) '************************************************************************************************* WshNetwork.MapNetworkDrive "H:", "\\cobcore2.ad.cob.ohio-state.edu\" & WshNetwork.UserName & "$" WshNetwork.MapNetworkDrive "P:", "\\cobcore2.ad.cob.ohio-state.edu\apps" WshNetwork.MapNetworkDrive "Q:", "\\cobcore2.ad.cob.ohio-state.edu\tools" WshNetwork.MapNetworkDrive "S:", "\\svosu.ad.cob.ohio-state.edu\stockval" '************************************************************************************************* ' Name global network drives (short strings for ease of understanding) '************************************************************************************************* Set WshShell = CreateObject("Shell.Application") WshShell.NameSpace("H:").Self.Name = "HOME" WshShell.NameSpace("P:").Self.Name = "APPS" WshShell.NameSpace("Q:").Self.Name = "TOOLS" WshShell.NameSpace("S:").Self.Name = "STKVAL" '************************************************************************************************* ' Obtain local PC IP and compare to labs.csv entries '************************************************************************************************* Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set IPConfigSet = objWMIService.ExecQuery ("Select IPAddress, MACAddress from Win32_NetworkAdapterConfiguration") Set fso = CreateObject("Scripting.FileSystemObject") Set MyFile = fso.OpenTextFile(SRCDATAFILE, 1, False) Do While MyFile.AtEndOfStream <> true line = MyFile.readline lineParts = split(line,",") For Each IPConfig in IPConfigSet If Not IsNull(IPConfig.IPAddress) Then For i=LBound(IPConfig.IPAddress) to UBound(IPConfig.IPAddress) If IPConfig.IPAddress(i) <> "0.0.0.0" Then strIpAddr = IPConfig.IPAddress(i) strMacAddr = IPConfig.MACAddress(i) If lineParts(0) = strIpAddr Then ipFound = true Exit Do End If End If Next End If Next Loop MyFile.close '*****************************************************************************************
From: mr_unreliable on 20 Jul 2006 17:36 Mandy, that's kinda a long script. Any indication as to what specific line is causing the error? cheers, jw Mandy wrote: > I'm getting runtime error 800A0035 when I run the following code.
From: Mandy on 21 Jul 2006 10:16 mr_unreliable wrote: > Mandy, that's kinda a long script. > > Any indication as to what specific line is causing the error? > > cheers, jw > > Mandy wrote: > > I'm getting runtime error 800A0035 when I run the following code. Yes sorry, It happening around line 97 I'll highlight the acutal commands below (look for the lines with several "&" around them, Thanks : '******************************************************** '*Title: Mapping Group Drive and Printer * '*Author: Mandy Dunn & Rob Kinney * '*Date: October 3, 2005 * '*Modified: October 3, 2005 * '******************************************************** '************************************************************************************************* ' Declare variables '************************************************************************************************* Dim WshSysInfo, WshUser, WshComputer, WshGroup, WshNet Dim WshShell Dim fso, MyFile, lineParts Dim strIpAddr, strMacAddr, strComputer, objWMIService Dim ipFound Dim SRCDATAFILE '************************************************************************************************* ' Create system connections for data extraction from host (IP, username, etc.) '************************************************************************************************* Set WshNetwork = WScript.CreateObject ("WScript.Network") Set WshSysInfo = Createobject("ADSystemInfo") Set WshUser = Getobject("LDAP://" & WshSysInfo.UserName) '************************************************************************************************* ' Test to see if computer is a member of "facstf Computers" or "student Computers" and ' map drives, printers accordingly '************************************************************************************************* Set WshGroup = GetObject("LDAP://CN=facstf Computers,OU=facstf,dc=ad,dc=cob,dc=ohio-state,dc=edu") If WshGroup.IsMember("LDAP://" & WshSysInfo.ComputerName) Then '************************************************************************************************* ' Force a grou policy update '************************************************************************************************* Set WshShell = CreateObject ("Wscript.Shell") WshShell.Run("%systemroot%\system32\gpupdate /force") Set WshShell = Nothing '************************************************************************************************* ' Map appropriate global network drives (H: is specific to user) '************************************************************************************************* WshNetwork.MapNetworkDrive "G:", "\\facstf\group$" WshNetwork.MapNetworkDrive "H:", "\\cobcore2.ad.cob.ohio-state.edu\" & WshNetwork.UserName & "$" '************************************************************************************************* ' Name global network drives (short strings for ease of understanding) '************************************************************************************************* Set WshShell = CreateObject("Shell.Application") WshShell.NameSpace("G:").Self.Name = "GROUP" WshShell.NameSpace("H:").Self.Name = "HOME" Else Set WshGroup = GetObject("LDAP://CN=student Computers,OU=groups,OU=student,dc=ad,dc=cob,dc=ohio-state,dc=edu") If WshGroup.IsMember("LDAP://" & WshSysInfo.ComputerName) Then '************************************************************************************************* ' This section will read in the labs.csv file and compare the IP of the machine to the file to set ' lab and machine specifics such as printers and default printer '************************************************************************************************* &&&&&&&&&&&&&&SRCDATAFILE = "labs.csv"&&&&&&&&&&&&&&&&&&&&&&&&& ' the csv file format = (ip,lab,printer group) strComputer = "." ipFound = false '************************************************************************************************* ' Force a grou policy update '************************************************************************************************* Set WshShell = CreateObject ("Wscript.Shell") WshShell.Run("%systemroot%\system32\gpupdate /force") Set WshShell = Nothing '************************************************************************************************* ' Map appropriate global network drives (H: is specific to user) '************************************************************************************************* WshNetwork.MapNetworkDrive "H:", "\\cobcore2.ad.cob.ohio-state.edu\" & WshNetwork.UserName & "$" WshNetwork.MapNetworkDrive "P:", "\\cobcore2.ad.cob.ohio-state.edu\apps" WshNetwork.MapNetworkDrive "Q:", "\\cobcore2.ad.cob.ohio-state.edu\tools" WshNetwork.MapNetworkDrive "S:", "\\svosu.ad.cob.ohio-state.edu\stockval" '************************************************************************************************* ' Name global network drives (short strings for ease of understanding) '************************************************************************************************* Set WshShell = CreateObject("Shell.Application") WshShell.NameSpace("H:").Self.Name = "HOME" WshShell.NameSpace("P:").Self.Name = "APPS" WshShell.NameSpace("Q:").Self.Name = "TOOLS" WshShell.NameSpace("S:").Self.Name = "STKVAL" '************************************************************************************************* ' Obtain local PC IP and compare to labs.csv entries '************************************************************************************************* Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set IPConfigSet = objWMIService.ExecQuery ("Select IPAddress, MACAddress from Win32_NetworkAdapterConfiguration") &&&&&&&&&&&&&&Set fso = CreateObject("Scripting.FileSystemObject")&&&&&&&& &&&&&&&&&&&&&&Set MyFile = fso.OpenTextFile(SRCDATAFILE, 1, False)&&&&&& Do While MyFile.AtEndOfStream <> true line = MyFile.readline lineParts = split(line,",") For Each IPConfig in IPConfigSet If Not IsNull(IPConfig.IPAddress) Then For i=LBound(IPConfig.IPAddress) to UBound(IPConfig.IPAddress) If IPConfig.IPAddress(i) <> "0.0.0.0" Then strIpAddr = IPConfig.IPAddress(i) strMacAddr = IPConfig.MACAddress(i) If linePart
From: mr_unreliable on 21 Jul 2006 13:53 OK, that clarifies it. First, does it fail all the time, or just sometimes? I noted that you are not supplying the full path to the file, just assuming that if it's in the same folder as the script then that's good enough. It may just be that the working directory (or current directory -- I get confused) for the system may not be the directory where the script is located. You may be safer to either set the working directory, or to just build up the entire path to the file (using the known path to the script), before attempting to retrieve the file. cheers, jw Mandy wrote: > mr_unreliable wrote: >> Mandy, that's kinda a long script. >> >> Any indication as to what specific line is causing the error? >> >> cheers, jw >> >> Mandy wrote: >>> I'm getting runtime error 800A0035 when I run the following code. > > Yes sorry, It happening around line 97 I'll highlight the acutal > commands below (look for the lines with several "&" around them, Thanks
From: Mandy on 26 Jul 2006 15:07 Hi, It fails all the time. The CSV file is contained in the same directory as the script but I've also tried it with th full path and I get a different error when I use it that way. In this state it just can't find the file. With the UNC path it tells me it's expecting a ")" but I've not managed to get it in the right place. I have managed to deploy this script successfully via group policy but I'd really like to run it from the user object. Thanks, Mandy mr_unreliable wrote: > OK, that clarifies it. > > First, does it fail all the time, or just sometimes? > > I noted that you are not supplying the full path to the file, > just assuming that if it's in the same folder as the script > then that's good enough. > > It may just be that the working directory (or current directory > -- I get confused) for the system may not be the directory where > the script is located. > > You may be safer to either set the working directory, or to just > build up the entire path to the file (using the known path to the > script), before attempting to retrieve the file. > > cheers, jw > > Mandy wrote: > > mr_unreliable wrote: > >> Mandy, that's kinda a long script. > >> > >> Any indication as to what specific line is causing the error? > >> > >> cheers, jw > >> > >> Mandy wrote: > >>> I'm getting runtime error 800A0035 when I run the following code. > > > > Yes sorry, It happening around line 97 I'll highlight the acutal > > commands below (look for the lines with several "&" around them, Thanks
|
Pages: 1 Prev: WMI Next: how to call vbe from wsf ? |