Jump to content

Recommended Posts

Posted

Hello

 

I have created a vbscript by cannibalising others on the interweb to install a printer port, the driver and then the actual printer. On some machines it works, on others i get the following error:

 

Script:     Install.vbs
Line:       34
Char:      1
Error:      Generic Failure
Code:      80041001
Source:   SWbemObjectEx

 

the vbscript looks like this:

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer &"\root\cimv2")
Set objNewPort = objWMIService.Get _
("Win32_TCPIPPrinterPort").SpawnInstance_

objNewPort.Name = "IP_x.x.x.206"
objNewPort.Protocol = 1
objNewPort.HostAddress = "x.x.x.206"
objNewPort.PortNumber = "9100"
objNewPort.SNMPEnabled = False
objNewPort.Put_

objWMIService.Security_.Privileges.AddAsString "SeLoadDriverPrivilege", True

Set objDriver = objWMIService.Get("Win32_PrinterDriver")

objDriver.Name = "HP Color LaserJet CP3505 PCL 6"
'objDriver.SupportedPlatform = "Windows NT x86"
'objDriver.Version = "3"
objInfname = "\\x.x.x.5\Apps\Printer Drivers\Konica Minolta BizHub C360\KOAZ8J__.inf"
intResult = objDriver.AddPrinterDriver(objDriver)

Set objPrinter = objWMIService.Get("Win32_Printer").SpawnInstance_

objPrinter.DriverName = "KONICA MINOLTA C360SeriesPCL"
objPrinter.PortName   = "IP_x.x.x.206"
objPrinter.DeviceID   = "KONICA MINOLTA C360SeriesPCL"
objPrinter.Location = "Printer Location"
objPrinter.Network = True
objPrinter.Shared = False
objPrinter.Put_

 

can anyone shed any light on this problem???

 

Thanks

Posted

I just used to use this:

 

set wshnet = CreateObject("WScript.Network")

wshnet.AddWindowsPrinterConnection "\\{printerservername}\{name of printer share 1}"

wshnet.AddWindowsPrinterConnection "\\{printerservername}\{name of printer share 2}"

WshNet.SetDefaultPrinter "\\{printerservername}\{name of default printer share}"

 

 

 

 

I now use Group Policy Preferences to deploy and assign printers.

 

Hope this helps

Posted

Whoops, sorry think that's my fault. Deleted what i thought were uneeded blank lines:

 

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer &"\root\cimv2")
Set objNewPort = objWMIService.Get _
("Win32_TCPIPPrinterPort").SpawnInstance_

objNewPort.Name = "IP_x.x.x.206"
objNewPort.Protocol = 1
objNewPort.HostAddress = "x.x.x.206"
objNewPort.PortNumber = "9100"
objNewPort.SNMPEnabled = False
objNewPort.Put_


objWMIService.Security_.Privileges.AddAsString "SeLoadDriverPrivilege", True

Set objDriver = objWMIService.Get("Win32_PrinterDriver")

objDriver.Name = "KONICA MINOLTA C360SeriesPCL"
'objDriver.SupportedPlatform = "Windows NT x86"
'objDriver.Version = "3"
objInfname = "\\x.x.x.5\Apps\Printer Drivers\Konica Minolta BizHub C360\KOAZ8J__.inf"
intResult = objDriver.AddPrinterDriver(objDriver)


Set objPrinter = objWMIService.Get("Win32_Printer").SpawnInstance_

objPrinter.DriverName = "KONICA MINOLTA C360SeriesPCL"
objPrinter.PortName   = "IP_x.x.x.206"
objPrinter.DeviceID   = "KONICA MINOLTA C360SeriesPCL"
objPrinter.Location = "Printer Location"
objPrinter.Network = True
objPrinter.Shared = False
objPrinter.Put_

 

With regards to MYK-IT: I can't use that method as we don't use a print server (not my decision!!!) Thanks anyway.

Posted

Admins please mark as solved if possible. It turns out that some versions of XP (not sure which) don't like the objPrinter.Put_ at the end of the script. putting a comment in at the end appears to resolve it.

 

:)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...