clients all work on XP machines,and we do direct IP printing. Setting
up a print server is not an option I want the script to add the IP
port, driver, and printer object. If the machine already has the driver
it works fine but if not, I get the same error message: Line 34; char
1; error: Generic failure; code 80041001; source SWbemObjectEx
here is my script where am i going wrong?

strOutput = ""

Set objWMIService = GetObject("winmgmts:")
Set objNewPort = objWMIService.Get _
("Win32_TCPIPPrinterPort").SpawnInstance_
objNewPort.Name = "IP_192.168.79.200"
objNewPort.Protocol = 1
objNewPort.HostAddress = "192.168.79.200"
objNewPort.PortNumber = "9100"
objNewPort.SNMPEnabled = False
objNewPort.Put_
strOutput = "Printer port IP_192.168.79.200 was created." & VBNewLine

strComputer = "."
sDir = Replace(WScript.ScriptFullName, WScript.ScriptName, "")
Set objWMIService = GetObject("winmgmts:" & _
"{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objDriver = objWMIService.Get("Win32_PrinterDriver")
objDriver.Name = "Xerox WorkCentre M55"
objDriver.SupportedPlatform = "Windows NT x86"
objDriver.Version = "3"
objDriver.FilePath = sDir + "\Xerox WorkCentre M55 PCL "
objDriver.InfName = sDir + "\\Xerox WorkCentre M55 PCL\XRB55PCL.INF"
intResult = objDriver.AddPrinterDriver(objDriver)
strOutput = strOutput & "Printer Driver for the Xerox WorkCentre Pro 55
printer was installed. Code: " & intResult &

VBNewLine

Set objPrinter = objWMIService.Get("Win32_Printer").SpawnInstance_
objPrinter.DriverName = "Xerox WorkCentre M55"
objPrinter.PortName = "IP_192.168.79.200"
objPrinter.DeviceID = "Xerox WorkCentre M55"
objPrinter.Network = True
objPrinter.Shared = False
objPrinter.ShareName = "Xerox WorkCentre M55"
objPrinter.Put_
WScript.Echo strOutput & "Xerox WorkCentre M 55 printer was installed."

Re: IPPrinter Script is not workding VBS by williamdavis1642

williamdavis1642
Wed Aug 24 10:06:49 CDT 2005

Try MS Tech article 189105 How to add printers with no user interaction

-Wdavis

tomliss@gmail.com wrote:
> clients all work on XP machines,and we do direct IP printing. Setting
> up a print server is not an option I want the script to add the IP
> port, driver, and printer object. If the machine already has the driver
> it works fine but if not, I get the same error message: Line 34; char
> 1; error: Generic failure; code 80041001; source SWbemObjectEx
> here is my script where am i going wrong?
>
> strOutput = ""
>
> Set objWMIService = GetObject("winmgmts:")
> Set objNewPort = objWMIService.Get _
> ("Win32_TCPIPPrinterPort").SpawnInstance_
> objNewPort.Name = "IP_192.168.79.200"
> objNewPort.Protocol = 1
> objNewPort.HostAddress = "192.168.79.200"
> objNewPort.PortNumber = "9100"
> objNewPort.SNMPEnabled = False
> objNewPort.Put_
> strOutput = "Printer port IP_192.168.79.200 was created." & VBNewLine
>
> strComputer = "."
> sDir = Replace(WScript.ScriptFullName, WScript.ScriptName, "")
> Set objWMIService = GetObject("winmgmts:" & _
> "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
> Set objDriver = objWMIService.Get("Win32_PrinterDriver")
> objDriver.Name = "Xerox WorkCentre M55"
> objDriver.SupportedPlatform = "Windows NT x86"
> objDriver.Version = "3"
> objDriver.FilePath = sDir + "\Xerox WorkCentre M55 PCL "
> objDriver.InfName = sDir + "\\Xerox WorkCentre M55 PCL\XRB55PCL.INF"
> intResult = objDriver.AddPrinterDriver(objDriver)
> strOutput = strOutput & "Printer Driver for the Xerox WorkCentre Pro 55
> printer was installed. Code: " & intResult &
>
> VBNewLine
>
> Set objPrinter = objWMIService.Get("Win32_Printer").SpawnInstance_
> objPrinter.DriverName = "Xerox WorkCentre M55"
> objPrinter.PortName = "IP_192.168.79.200"
> objPrinter.DeviceID = "Xerox WorkCentre M55"
> objPrinter.Network = True
> objPrinter.Shared = False
> objPrinter.ShareName = "Xerox WorkCentre M55"
> objPrinter.Put_
> WScript.Echo strOutput & "Xerox WorkCentre M 55 printer was installed."