Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printer - Tray Selection

Status
Not open for further replies.

adamctb

Programmer
Jun 27, 2006
4
GB
Hi,

I use the below vbscript to setup a network printer on user logon. The script works fine however i want to do the same thing for our HP Laserjet 4250 printers. The problem i have is that i need to change the default paper tray from auto-select (which goes to tray 3) to Tray 2 for certain users (as they print to a different headed paper from the one in tray 3). Any suggestions you can provide would be most appreciated, Thanks.

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

set objNewPort = objWMIService.get("Win32_TCPIPPrinterPort").SpawnInstance_
Set objPrinter = objWMIService.Get("Win32_Printer").SpawnInstance_
objWMIService.Security_.Privileges.AddAsString "SeLoadDriverPrivilege", True
Set objDriver = objWMIService.Get("Win32_PrinterDriver")

objDriver.Name = "HP LaserJet 2100" '<-- Driver name in INF file
objDriver.SupportedPlatform = "Windows NT x86"
objDriver.Version = "3"
objDriver.FilePath = "C:\lj2100pcl6win2kxp2003\hpbf212i" '<-- Path to inf file
objDriver.Infname = "C:\lj2100pcl6win2kxp2003\hpbf212i.inf" '<-- Path and name if inf file
intResult = objDriver.AddPrinterDriver(objDriver)

'Installs Printer Port
objNewPort.Name = "10.0.0.247" '<-- change to the port address or name
objNewPort.Protocol = 1
objNewPort.HostAddress = "10.0.0.247" '<-- change to the port address or name
'objNewPort.PortNumber = 9100 <-- Change to appropriate port number if needed
objNewPort.SNMPEnabled = True
objNewPort.Put_

'Install Printer
objPrinter.DriverName = "HP LaserJet 2100" '<-- change to match the driver name in the INF same as first line above
objPrinter.PortName = "10.0.0.247" '<-- change to the port address or name
objPrinter.DeviceID = "Andrew" '<-- Friendly name displayed in control panel
objPrinter.Location = ""
objPrinter.Network = True
objPrinter.Put_
 
doesnt seem to be much documented on it, or at least writeable properties for trays, have you had a look at the Parameters property of hte Win32_Class and see what is in it for your printer instance?

how about trying a regsnap before and after changing the printer settings? it might be in the registry somewhere?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top