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!

Create an .bat to install multiple printers

Status
Not open for further replies.

Nofeark21

Technical User
Dec 27, 2006
30
US
Not sure if this is the best loaction for this post.
So here's my scenario.

I installed a new server and am removing the old one. I have several departments that have multiple printers to connect to. I copied all the printers from the old server to the new one.

What I would like to do is create a batch file so the printers for each department will install from the new server using one click versus installing them all one-by-one.
Can someone help me get started with that? Are there any whitepapers or articles that relate to this that someone can direct me towards.
Any help would be much appreciated.
 
Here are the bits from Marks script that should do what you want, it starts by deleting all local printers then adding any that you specify and setting one as a default printer.

Code:
Option Explicit

On error resume next

Dim WSHShell, WSHNetwork, Network, WSHPrinters, LOOP_COUNTER, Path



Set WSHNetwork = CreateObject("WScript.Network")
Set Network = CreateObject("Wscript.Network") 



'Remove ALL old printers
'Enumerate all printers first, after that you can select the printers you want by performing some string checks

Set WSHPrinters = WSHNetwork.EnumPrinterConnections
For LOOP_COUNTER = 0 To WSHPrinters.Count - 1 Step 2
'To remove only networked printers use this If Statement
    If Left(WSHPrinters.Item(LOOP_COUNTER +1),2) = "\\" Then
      WSHNetwork.RemovePrinterConnection WSHPrinters.Item(LOOP_COUNTER +1),True,True
    End If
'To remove all printers incuding LOCAL printers use this statement and comment out the If Statement above
'WSHNetwork.RemovePrinterConnection WSHPrinters.Item(LOOP_COUNTER +1),True,True
Next


'Remove a specific printer
'WSHNetwork.RemovePrinterConnection "\\ServerOld\HP5si",True,True
      
                          
'Install Printers


WSHNetwork.AddWindowsPrinterConnection "\\Server\HP5si"

WSHNetwork.AddWindowsPrinterConnection "\\Server\HPprinter2"
Network.SetDefaultPrinter "\\Server\HPprinter2"


'Clean Up Memory Used

set WSHNetwork = Nothing
set WSHSHell = Nothing
Set WSHPrinters = Nothing
Set Network = Nothing
  
'Quit the Script
wscript.quit
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top