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 logon rehash

Status
Not open for further replies.

RKizer

MIS
Feb 15, 2008
11
US
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.
 
You may create the port in the startup script.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I can create the port in the start up script but would need administrator rights to install the printer. I'm guessing a "runas" or similar command code would do it, but would it need to be a different script entirely?
 
I found the answer to my problem. If you set the group Policy on the local machine to allow "users" to install printers and drivers, the logon script works.

As we will be installing a ghost image to all systems on a new PC roll out, we will simply make the GP edit for the original image.

Here is the link where I found the needed info.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top