Saturday, April 3, 2010

Clear and Add network printers

Here is a handy VB script that I have cobbled together. Some from the web, etc.

set net = CreateObject ("WScript.Network")

'deletes all network printers
Set clPrinters = net.EnumPrinterConnections
For i = 0 to clPrinters.Count - 1 Step 2
clPrinters.Item(i)& " " & i+1
net.RemovePrinterConnection clPrinters.Item(i+1), true
Next

'maps new printers.
net.AddWindowsPrinterConnection "\\print_server_name\printer name", "description"
net.AddWindowsPrinterConnection "\\print_server_name\printer name", "description"
net.AddWindowsPrinterConnection "\\print_server_name\printer name", "description"
net.SetDefaultPrinter "\\print_server_name\printer name"

Wscript.Quit

No comments: