We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

Printer Mappings

Medium Priority
496 Views
Last Modified: 2012-05-11
I have a situation where we are moving out print/application servers to a collocation facility. When this happens the all printers will be removed from the servers as we cannot print over the VPN tunnel due to latency concerns. My boss wants me to set up each local machine to print directly to a network printer. I would like to be able to leverage batch files, vb scripts, or GPO's to simplify my task and to avoid having to manually touch each machine.

My vision is to have a script that would allow me to store the printer driver files on the file server in the collocation facility and leverage a script that references the UNC path to the drivers as it creates a local printer on each workstation. The script would create the local printer using the TCP/IP address of the network printer.

Does anyone have any ideas?
Comment
Watch Question

CERTIFIED EXPERT

Commented:
You could try something like this with VBScript...

 
Option Explicit
On Error Resume Next
Dim objWMIService
Dim strComputer
Dim objNewPort
Dim objDriver
Dim intResult
Dim objPrinter

strComputer = "."

'Create the port
Set objWMIService = GetObject("winmgmts:" _ 
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") 
Set objNewPort = objWMIService.Get _ 
("Win32_TCPIPPrinterPort").SpawnInstance_ 

objNewPort.Name = "IP_10.10.10.10" 
objNewPort.Protocol = 1 
objNewPort.HostAddress = "10.10.10.10"
objNewPort.SNMPEnabled = False 
objNewPort.Put_ 

'Install the driver
Set objWMIService = GetObject("winmgmts:" _ 
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") 
objWMIService.Security_.Privileges.AddAsString "SeLoadDriverPrivilege", True 
 
Set objDriver = objWMIService.Get("Win32_PrinterDriver") 
 
objDriver.Name = "RICOH Aficio 2022 RPCS" 	'Driver Name
objDriver.Infname = "\\Server\Share\ricoh\RC1AE12K.INF"
intResult = objDriver.AddPrinterDriver(objDriver)

'Install the printer
Set objPrinter = GetObject( _
    "winmgmts:{impersonationLevel=Impersonate ," _
    & "(LoadDriver)}!//./root/cimv2:Win32_Printer")

Set objPrinter = objWMIService.Get("Win32_Printer").SpawnInstance_

objPrinter.DriverName = "RICOH Aficio 2022 RPCS"
objPrinter.PortName = "IP_10.10.10.10"
objPrinter.DeviceID = "Ricoh Printer"	'Printer Name
objPrinter.Location = "HR"
objPrinter.Network = True
objPrinter.Shared = False
'objPrinter.ShareName = "ShareName"
objPrinter.Put_

Open in new window

Author

Commented:
This is the script I used but it didn't work and I got no error message feedback. How can I figure out whats wrong?
Option Explicit
On Error Resume Next
Dim objWMIService
Dim strComputer
Dim objNewPort
Dim objDriver
Dim intResult
Dim objPrinter

strComputer = "."

'Create the port
Set objWMIService = GetObject("winmgmts:" _ 
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") 
Set objNewPort = objWMIService.Get _ 
("Win32_TCPIPPrinterPort").SpawnInstance_ 

objNewPort.Name = "IP_172.16.200.30" 
objNewPort.Protocol = 1 
objNewPort.HostAddress = "172.16.200.30"
objNewPort.SNMPEnabled = False 
objNewPort.Put_ 

'Install the driver
Set objWMIService = GetObject("winmgmts:" _ 
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") 
objWMIService.Security_.Privileges.AddAsString "SeLoadDriverPrivilege", True 
 
Set objDriver = objWMIService.Get("Win32_PrinterDriver") 
 
objDriver.Name = "HP LaserJet P3005 PCL 6" 	'Driver Name
objDriver.Infname = "\\AHGFS\HP\hpc300xc.inf"
intResult = objDriver.AddPrinterDriver(objDriver)

'Install the printer
Set objPrinter = GetObject( _
    "winmgmts:{impersonationLevel=Impersonate ," _
    & "(LoadDriver)}!//./root/cimv2:Win32_Printer")

Set objPrinter = objWMIService.Get("Win32_Printer").SpawnInstance_

objPrinter.DriverName = "HP LaserJet P3005 PCL 6"
objPrinter.PortName = "IP_172.16.200.30"
objPrinter.DeviceID = "HP LaserJet P3005"	'Printer Name
objPrinter.Location = "Business Office"
objPrinter.Network = True
objPrinter.Shared = False
'objPrinter.ShareName = "HPLJP3005PCL6"
objPrinter.Put_

Open in new window

CERTIFIED EXPERT
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview

Author

Commented:
I will try this
CERTIFIED EXPERT

Commented:
I've requested that this question be closed as follows:

Accepted answer: 500 points for yelbaglf's comment http:/Q_26979439.html#35503839

for the following reason:

This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.

Author

Commented:
I object I want to award points never got around to rewarding them
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.