Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


error 2147217405

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,47172
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> error 2147217405
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 error 2147217405 - 5/17/2007 1:03:32 PM   
  aburt

 

Posts: 104
Score: 0
Joined: 12/4/2006
Status: offline
I have a script that checks the local clients Ip address and install a printer based on the range the client IP address. 

On several clients I am getting error 2147217405  when I try to run this script via SMS.  The script is downloaded to the client and if I use psexec to run the my script on the remote machine it works fine.  Can anybody tell me what error code 2147217405

Here is the script.

Option Explicit
Dim strComputer : strComputer = "."
Dim objNetwork : Set objNetwork = CreateObject("WScript.Network")
Dim localIP  :  localIP = ResolveIP(objNetwork.ComputerName)
Dim arrIPOct  :  arrIPOct = Split(localIP, ".")
Dim intOct3  :  intOct3 = CInt(arrIPOct(2))
Dim intOct4  : intOct4 = CInt(arrIPOct(3))
Dim Location1, Location2, Location3, Location4
Dim Location, IP
Dim Printer, FilePath
Dim objShell, objNewPort, objWMIService
Dim RunErrorToReturn, Results
If (intOct3 >= 1 And intOct3 <= 15) And (intOct4 >= 3 And intOct4 <= 30) Then 'If (intOct3 >= 1 And intOct3 <= 3) And (intOct4 >= 3 And intOct4 <= 30) Then
     IP = "x.x.1.a"
     Printer = "-Location1" 
     Location = "Location1"
  'WScript.Echo "Match x.x.1.3 - x.x.1.30: " & localIP
ElseIf (intOct3 >= 1 And intOct3 <= 15) And (intOct4 >= 35 And intOct4 <= 62) Then 'ElseIf (intOct3 >= 1 And intOct3 <= 15) And (intOct4 >= 35 And intOct4 <= 62) Then
     IP = "x.x.1.b"
     Printer = "-Location2"
     Location = "Location2"
     'WScript.Echo "Match x.x.1.35 - x.x.1.35: " & localIP
ElseIf (intOct3 >= 1 And intOct3 <= 15)And (intOct4 >= 67 And intOct4 <=94) Then 'ElseIf (intOct3 >= 1 And intOct3 <= 15)And (intOct4 >= 67 And intOct4 <=94) Then
     IP = "x.x.1.c"
     Printer = "-Location3"
     Location = "Location3"
     WScript.Echo "Match x.x.1.67 - x.x.1.94: " & localIP
ElseIf (intOct3 >= 1 And intOct3 <= 33) And (intOct4 >= 99 And intOct4 <=126) Then 'ElseIf (intOct3 >= 1 And intOct3 <= 15) And (intOct4 >= 99 And intOct4 <=126) Then
     IP = "x.x.1.d"
      Printer = "-Location4"
     Location = "Location4"
     'WScript.Echo "Match x.x.1.99 - x.x.1.126: " & localIP
ElseIf (intOct3 >= 1 And intOct3 <= 15) And (intOct4 >= 131 And intOct4 <=158) Then 'ElseIf (intOct3 >= 1 And intOct3 <= 15) And (intOct4 >= 131 And intOct4 <=158) Then
     IP = "x.x.1.e"
     Printer = "-Location5"
     Location = "Location5"
     'WScript.Echo "Match x.x.1.99 - x.x.1.126: " & localIP
End If

Function ResolveIP(computerName)
Dim objShell  :  Set objShell = CreateObject("WScript.Shell")
Dim objExec   :  Set objExec = objShell.Exec("ping " & computerName & " -n 1")
Dim RegEx     :  Set RegEx = New RegExp
RegEx.Pattern = "\[(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\]"
RegEx.IgnoreCase = True
RegEx.Global = True
ResolveIP = RegEx.Execute(objExec.StdOut.ReadAll)(0).Submatches(0)
End Function
Set objWMIService = GetObject("winmgmts:"_
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objNewPort = objWMIService.Get _
("Win32_TCPIPPrinterPort").SpawnInstance_
Set objShell = CreateObject("WScript.Shell")
objNewPort.Name = "IP_" & IP
objNewPort.Protocol = 1
objNewPort.HostAddress = IP
objNewPort.PortNumber = "9100"
objNewPort.SNMPEnabled = False
objNewPort.Put_
FilePath =  Split(WScript.ScriptFullName, WScript.ScriptName)(0) & "hppcp602.inf"
'WScript.Echo FilePath
'This Is For Printer Driver
objShell.Run "rundll32 printui.dll, PrintUIEntry /if /b " &  Chr(34)& "Printer" & Printer & Chr(34) & " /f "& _
FilePath & " /r " & Chr(34)& "IP_" & IP & Chr(34) & " /m " & """Printer"""
 
 
Post #: 1
 
 RE: error 2147217405 - 5/17/2007 1:41:12 PM   
  aburt

 

Posts: 104
Score: 0
Joined: 12/4/2006
Status: offline
My apologies wrong group

(in reply to aburt)
 
 
Post #: 2
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> error 2147217405 Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts