Thursday, October 12, 2006

Tech Tip: Setting up networked Windows printers with a double-click!

The automation of setting up networked printers under Microsoft Windows 2000/XP can be easily automated using a simple Visual Basic script (.vbs).

This can be added into Active Directory to run upon startup or can be run by each individual user at any time.

To get this script to work, you need to know the server the printer's queue runs from, and the name of the printer on that server. You can use this script to install multiple printers at the same time too.

The script takes the following form:


' Printers.vbs - Printer Setup Script
' Basic network setup
Option Explicit
Dim objNetwork
Dim strUNCPrinter
Set objNetwork = CreateObject("WScript.Network")

' if anything goes wrong, ie a printer cannot be found, skip to the next one
On error resume next

' add in as many as you like, the basic form is:
' objNetwork.AddWindowsPrinterConnection "\\SERVERNAME\PrinterName"
objNetwork.AddWindowsPrinterConnection "\\print_server\Printer_01"
objNetwork.AddWindowsPrinterConnection "\\print_server\Printer_15"
objNetwork.AddWindowsPrinterConnection "\\print_server\Printer_09"
objNetwork.AddWindowsPrinterConnection "\\other_server\Printer_12"

' You can change the text to say something else here if you wish
WScript.Echo "Printer Setup Complete!"

WScript.Quit

' End printers script.


When you run the script (it may take a minute..) you will see the following:



Copy and paste the script into a text editor (like Notepad) and save as printers.vbs. To run it, double-click the file in Windows Explorer. You could also set it up to run upon login using Active Directory.

Technorati tags:
Windows | Netowrk Printers | Visual Basic | WSH