• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 484
  • Last Modified:

Printer Mappings

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?
0
dallasgrp
Asked:
dallasgrp
  • 3
  • 2
1 Solution
 
yelbaglfCommented:
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

0
 
dallasgrpAuthor 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

0
 
yelbaglfCommented:
You'll want to comment out the 'On Error Resume Next' during troubleshooting...


 
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

0
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 
dallasgrpAuthor Commented:
I will try this
0
 
hdhondtCommented:
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.
0
 
dallasgrpAuthor Commented:
I object I want to award points never got around to rewarding them
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now