Jump to content

Printer Scripts (Again!) Using VBS


Recommended Posts

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 = "SAVIN MLP25n PCL 5e" '<-- Driver name in INF file
objDriver.SupportedPlatform = "Windows NT x86"
objDriver.Version = "3"
objDriver.FilePath = "\\255.255.255.255\Printer Script Drivers\Savin MLP25_MLP25N" '<-- Path to inf file
objDriver.Infname = "\\255.255.255.255\Printer Script Drivers\Savin MLP25_MLP25N\OEMSETUP.INF" '<-- Path and name if inf file
intResult = objDriver.AddPrinterDriver(objDriver)

'Installs Printer Port
objNewPort.Name = "IP_255.255.255.255" '<-- change to the port address or name
objNewPort.Protocol = 1
objNewPort.HostAddress = "255.255.255.255" '<-- 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 = "SAVIN MLP25n PCL 5e" '<-- change to match the driver name in the INF same as first line above
objPrinter.PortName = "IP_255.255.255.255" '<-- change to the port address or name
objPrinter.DeviceID = "Pritner1" '<-- Friendly name displayed in control panel
objPrinter.Location = ""
objPrinter.Network = True
objPrinter.Put_

Here is the code I currently have. It basically install a printer with default settings.

What I need is a way to automate which trays are activated on a per printer basis. The options I can think of is adding to this VBS script, or using a batch file. I'd even be willing to use registry settings if that is the best way.

Thanks for your input.

(I changed the important things to be somewhat private. No I don't use broadcast IP's.)

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...