Jump to content

Help troubleshooting printer management

Recommended Posts

Ok, I'm hoping someone here can spot a problem that I'm missing.

I'm in the process of converting all my workstations from printing through a print server to using TCP/IP ports. To make things easier, I'm scripting what I can.

The script below is an example of what I'm doing, for an HP LaserJet P3005 and a Color LaserJet 3600.

It works beautifully for both on x64, and for the color on x86, but with the p3005 on x86, I get an "Operation could not be completed" error. Since the only differences between the commands seem to be the driver, it would be the likely culprit. But on the same x86 XP box that throws the error, I can manually install that same driver with no problem. I'm attaching the .inf file in case it helps.

Also, that box already had a P3005 PCL6 driver, so the /u switch on PrintUIEntry should have ignored the driver path, right?

Anybody see something I'm missing?


InstallPrinter("HS Lobby 1","","p3005")
InstallPrinter("HS Lab Color","","clj3600")

Func InstallPrinter($PrName,$Address,$Driver,$Prompt=0)

Local $msg
If $Prompt = 1 Then $msg = MsgBox(35,"Question","Install "&$PrName&"?")
If $msg = 2 Then Exit
If $msg = 7 Then Return

$objWMIService = ObjGet("winmgmts:\\" & @ComputerName & "\root\cimv2")
$objNewPort = $objWMIService.Get("Win32_TCPIPPrinterPort").SpawnInstance_

$objNewPort.Name = "IP_"&$Address
$objNewPort.Protocol = 1
$objNewPort.HostAddress = $Address
$objNewPort.PortNumber = "9100"
$objNewPort.SNMPEnabled = False

$DriverPath = "\\server\util\drivers\"&@OSArch&"\printers"

;I've removed several of the Cases here for brevity.

Case @OSArch="x86" AND $Driver="p3005"
$LocalPath = $DriverPath & "\ljp3005.pcl6\hpc300xc.inf"
$Model = "HP LaserJet P3005 PCL 6"
Case @OSArch="x64" AND $Driver="p3005"
$LocalPath = $DriverPath & "\ljp3005.pcl6\hpc300xu.inf"
$Model = "HP LaserJet P3005 PCL 6"
Case @OSArch="x86" AND $Driver="clj3600"
$LocalPath = $DriverPath & "\clj3600\hpc3600e.inf"
$Model = "HP Color LaserJet 3600"
Case @OSArch="x64" AND $Driver="clj3600"
$LocalPath = $DriverPath & "\clj3600\hpc3600w.inf"
$Model = "HP Color LaserJet 3600"
Case $Driver="wc5135"
$LocalPath = $DriverPath & "\wc5135.ps\x2WPENP.inf"
$Model = "Xerox WorkCentre 5135 PS"
Case $Driver="d2150"
$LocalPath = $DriverPath & "\d2150.pcl6\dlxrozi.inf"
$Model = "Dell 2150cdn Color Printer PCL6"

RunWait('rundll32 printui.dll,PrintUIEntry /if /b "'&$PrName&'" /f "'&$LocalPath&'" /r "IP_'&$Address&'" /m "'&$Model&'" /u')



Link to comment
Share on other sites

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...