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