Hello all, I'm new to the forums here but have gotten some good info here in the past and decided to join.
In a previous thread, thread329-1383515, sparkbyte had posted some good code that will create an IP port for a local printer and load the printer driver. I tested it locally and in a log on script and it works well, but only as long as the user is an administrator.
I need some help getting it to run in a logon script so "power users" can get their printers installed.
Below is the exact code from the original thread.
strIP = "192.168.1.100"
strPort = "9100"
strPrinterName = "2nd Floor HP Printer"
strLocation = "2nd Floor"
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objNewPort = objWMIService.Get _
("Win32_TCPIPPrinterPort").SpawnInstance_
objNewPort.Name = "IP_" & strIP
objNewPort.Protocol = 1
objNewPort.HostAddress = strIP
objNewPort.PortNumber = strPort
objNewPort.SNMPEnabled = False
objNewPort.Put_
'strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objPrinter = objWMIService.Get("Win32_Printer").SpawnInstance_
objPrinter.DriverName = "HP LaserJet 4000 Series PS"
objPrinter.PortName = "IP_" & strIP
objPrinter.DeviceID = strPrinterName
objPrinter.Location = strLocation
objPrinter.Network = False 'True
objPrinter.Shared = False ' True
'objPrinter.ShareName = "ScriptedPrinter"
objPrinter.Put_
Any help would be appreciated.
In a previous thread, thread329-1383515, sparkbyte had posted some good code that will create an IP port for a local printer and load the printer driver. I tested it locally and in a log on script and it works well, but only as long as the user is an administrator.
I need some help getting it to run in a logon script so "power users" can get their printers installed.
Below is the exact code from the original thread.
strIP = "192.168.1.100"
strPort = "9100"
strPrinterName = "2nd Floor HP Printer"
strLocation = "2nd Floor"
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objNewPort = objWMIService.Get _
("Win32_TCPIPPrinterPort").SpawnInstance_
objNewPort.Name = "IP_" & strIP
objNewPort.Protocol = 1
objNewPort.HostAddress = strIP
objNewPort.PortNumber = strPort
objNewPort.SNMPEnabled = False
objNewPort.Put_
'strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objPrinter = objWMIService.Get("Win32_Printer").SpawnInstance_
objPrinter.DriverName = "HP LaserJet 4000 Series PS"
objPrinter.PortName = "IP_" & strIP
objPrinter.DeviceID = strPrinterName
objPrinter.Location = strLocation
objPrinter.Network = False 'True
objPrinter.Shared = False ' True
'objPrinter.ShareName = "ScriptedPrinter"
objPrinter.Put_
Any help would be appreciated.