Printer Script doesn't work

poseidon

Beta member
Messages
2
Location
Netherlands
I want to add a printer with VBScript.

The one I'm using is.

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

strIPAddress = "192.168.226.6"
strDriverName = "HP Universal Printing PCL 6"
strQueueName = "HP OfficeJet Pro 8600"
strLocation = "Helpdesk"

'--- in case the driver is already there
REM *** Installs printer driver needed for Universal PLC6 64 Bit
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
objWMIService.Security_.Privileges.AddAsString "SeLoadDriverPrivilege", True

Set objDriver = objWMIService.Get("Win32_PrinterDriver")

objDriver.Name = "HP Universal Printing PCL 6"
objDriver.SupportedPlatform = "Windows NT x64"
objDriver.Version = "3"
objDriver.DriverPath = "C:\___Niet werkende drivers\HP Universal Print Driver\pcl6-x64-5.7.0.16448\"
objDriver.Infname = "C:\___Niet werkende drivers\HP Universal Print Driver\pcl6-x64-5.7.0.16448\hpcu155u.inf"
intResult = objDriver.AddPrinterDriver(objDriver)

rem *** Installs a TCP/IP printer local port on a computer
Set objNewPort = objWMIService.Get _
("Win32_TCPIPPrinterPort").SpawnInstance_
objNewPort.Name = "IP_" & strIPAddress
objNewPort.Protocol = 1
objNewPort.HostAddress = "."
objNewPort.SNMPEnabled = False
objNewPort.Put_

rem *** installs printer
Set objPrinter = objWMIService.Get("Win32_Printer").SpawnInstance_
objPrinter.DriverName = strDriverName
objPrinter.PortName = "IP_" & strIPAddress
objPrinter.DeviceID = strQueueName
objPrinter.Location = strLocation
objPrinter.Put_


As you can see I'm using a "HP Universal Printing PCL 6" driver.

Can anybody please help me

Thanks in advance.

Poseidon
 
So what part of it doesn't work? Have you tried stepping through each line of your code to see if it's working like it should?
 
I found what i did wrong.

I tried to add a inkjet printer with the universal pcl 6 driver from HP.
After replacing it with the original driver the script worked.

Thanks Carnagex for the fast reply.
 
Back
Top Bottom