QBNKRaCKeR
IS-IT--Management
Hi everybody,
I’m writing a script to install network printers via TCP/IP ports and the drivers are not in Drivers.cab. I get a generic error whenever I execute the script and I realized that the drivers are not being installed. I’ve looked at tons of examples on how to install the drivers but I cannot see what is wrong with my code. I know all the information is correct because I was able to install the printer via a batch file. The only wildcard is the driver path, but there is only one DLL in the driver folder and I’m assuming that it is the correct one. Any help will be greatly appreciated.
I’m writing a script to install network printers via TCP/IP ports and the drivers are not in Drivers.cab. I get a generic error whenever I execute the script and I realized that the drivers are not being installed. I’ve looked at tons of examples on how to install the drivers but I cannot see what is wrong with my code. I know all the information is correct because I was able to install the printer via a batch file. The only wildcard is the driver path, but there is only one DLL in the driver folder and I’m assuming that it is the correct one. Any help will be greatly appreciated.
Code:
Set WSHNetwork = WScript.CreateObject("WScript.Network")
Set Shell = WScript.CreateObject("WScript.Shell")
CompName = Shell.ExpandEnvironmentStrings("%COMPUTERNAME%")
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & CompName & "\root\cimv2")
objWMIService.Security_.Privileges.AddAsString "SeLoadDriverPrivilege", True
Set objNewPort = objWMIService.Get("Win32_TCPIPPrinterPort").SpawnInstance_
Set objDriver = objWMIService.Get("Win32_PrinterDriver")
Set objPrinter = objWMIService.Get("Win32_Printer").SpawnInstance_
objNewPort.Name = "IP_192.168.105.31"
objNewPort.Protocol = 1
objNewPort.HostAddress = "192.168.105.31"
objNewPort.SNMPEnabled = False
objNewPort.Put_
objDriver.Name ="HP LaserJet 4345 mfp PCL 6"
objDriver.SupportedPlatform = "Windows NT x86"
objDriver.Version = "3"
objDriverPath = "\\rcnyfs1\Technology\drivers\Print drivers\HP LJ4345 MFP\hpbicoin.dll"
objInfname = "\\rcnyfs1\Technology\drivers\Print drivers\HP LJ4345 MFP\hpc4345c.inf"
intResult = objDriver.AddPrinterDriver(objDriver)
objPrinter.DriverName ="HP LaserJet 4345 mfp PCL 6"
objPrinter.PortName ="IP_192.168.105.31"
objPrinter.DeviceID = "LJ 4345"
objPrinter.Location = ""
objPrinter.Network = True
objPrinter.Shared = false
objPrinter.ShareName = ""
objPrinter.Put_