This is the code I'm using to add my IP printer through a script but
only seems to add the port and not the printer to the machine. Can
anyone tell what would keep the printer from getting added to the
computer?


strComputer = "."


'= strComputer can be an array of netbios computer names or =
'= ip addresses put into a for loop =


Public Error
Dim Count:Count=0
Set WshShell = WScript.CreateObject("WScript.Shell")
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root
\cimv2")
Dim IPArray



'= here is where your editing skills happen! =

IPArray = Array( "172.17.20.136")
Dim PrintersArray


'= here is where your editing skills happen again ! =


PrintersArray=Array("c:\hpc2800d.inf")


'= here is where you edit the printer names =


Dim PrinterNames
PrinterNames=Array("HP Color LaserJet 2800 (Remote Office)")

For n = LBound(IPArray) To UBound(IPArray)
'Install the IP printer ports
Install_IP_Ports IPArray(n)
Next
For n = LBound(IPArray) To UBound(IPArray)
Count = Count + 1 'just increments the counter for the message at the
end!


'= Add the printers (Arguments: ip port, path to the .inf files,
printer name) =
'= get the name from the inf files or make one up! =


Add_local_ip_printer IPArray(n), PrintersArray(n), PrinterNames(n)
Next
Make_Default_printer PrinterNames(0)


'= if only one printer in array set to zero e.g. PrinterNames(0) or
comment out!=


'Install the TCP/IP Port(s):

Function Install_IP_Ports(strIPAddress)
Set objNewPort =
objWMIService.Get("Win32_TCPIPPrinterPort").SpawnInstance_
objNewPort.Name = strIPAddress
objNewPort.Protocol = 1
objNewPort.HostAddress = strIPAddress
objNewPort.PortNumber = "9100"
'objNewPort.Queue = "LPT1_PASSTHRU"
objNewPort.SNMPCommunity = "public"
objNewPort.SNMPEnabled = False
objNewPort.Put_
'stop the spooler
Set colServiceList = objWMIService.ExecQuery _
("Select * from Win32_Service where Name='Spooler'")
For Each objService In colServiceList
errReturn = objService.StopService()
WScript.Sleep 100
Next

'start the spooler

For Each objService In colServiceList
errReturn = objService.StartService()
WScript.Sleep 100
Next

End Function

Function
Add_local_ip_printer(strIP,strPath_To_Inf_Files,strPrintername)
WSHShell.run ("CMD.EXE /C RUNDLL32 PRINTUI.DLL,PrintUIEntry /if /b "_
& chr(34) & strPrinterName & chr(34) &" /f " & chr(34) _
& strPath_To_Inf_Files & chr(34) & " /r " & chr(34) _
& strIP & chr(34) & " /m " & chr(34) & strPrinterName & chr(34) _
& " /q /u"),0,true
End Function

Function Make_Default_printer(strPrinterName)
Set colInstalledPrinters = objWMIService.ExecQuery _
("Select * from Win32_Printer")
For Each objPrinter in colInstalledPrinters
If objPrinter.Name = strPrinterName Then
objPrinter.SetDefaultPrinter()
End If
Next
End Function

Wscript.echo "Script Completed " & count & " Printers Added"
'End Script