Introduction to Printer Logon Scripts
I designed this page as a mini site map for printer logon scripts. In this section I will help you create
VBScripts, which map printers and also set the default printer on Windows networks. You may be surprised by the sheer variety of Windows logon scripts that control printing. Along the journey, I will
provide examples of VBScript methods. For example, AddWindowsPrinterConnection, which connects a shared printer to an XP, Windows 2003 or even Windows 9x clients.
Topics for Printer Windows Logon Scripts
Microsoft's printer terminology can be pedantic; nevertheless, we really do need to check the meaning of keywords. So, to make sure that we are all singing from the same hymn sheet, here is a quick review of printer terms:
Printer: the
Icon in the Printer and Faxes
folder. The software interface, which manages the printer properties. After you run your scripts on the client, navigate, Start Menu, Control Panel, Printers and see examine any new
icons. Print Device: the hardware. The physical Epson, HP, or Brother device where you stuff its tray with paper or check its cable connections. Note: Obviously, the logon script will not install the actual printer device on the print
server, I assume that you will do that manually before running the VBscript. Network Printer: a printer with its own network card. Usually managed from a print server. Once it's shared
it behaves like the classic printer.
Printer Driver: I think of the driver as a software 'jockey' who rides the printer. What you need to know, is that Windows 2003 and XP clients, automatically install their own drivers across the network.
With modern clients, there is no scripting for drivers, no user
intervention with floppy disks - marvellous. The only danger is scratching your head and thinking 'how do script the drivers', no need - unless you have Window 9x. Default printer: if a user just hits the
print button from inside Word for Windows or similar software, the print job goes to whichever printer is assign as the default. Good news, you can script the default printer.
VBS Printer MethodsVBScripts have three components an object, a method, and a value. I will show you how to create objNetwork, apply the
method and assign a value to your shared network printer.
What gives any scripting language its power is the methods or verbs. Here is a list of specialist printing methods.
Printers verbs have fewer arguments than network drives. For example AddWindowsPrinterConnection only needs one 'argument', the name of the UNC path to the printer. RemovePrinterConnection
rewards your research because it supports the bForce argument, which disconnects the printer - ready or not. It also has the the bUpdateProfile which saves the changes to the user's profile.
SetDefaultPrinter and EnumPrinterConnections only needs one 'argument' the name of the printer! Our mission is to create a script, which maps a shared printer, and puts an Icon in the Printers (and Faxes) folder. The concept is similar to
mapping an network drive, but with printers rather than a home directory. Instead of receiving an extra drive letter in explorer, the users get an extra icon in the Printers folder. As with so many scripting tasks, these scripts are the equivalent of manual operations, in this case, opening the Printers and
Faxes folder, then selecting, Add Printer. Just to get you started here is a simple Windows Logon
Script. Our objective is to connect the client to a shared printer called
\\alan\Epson. Printer scripts have a variety of different methods, here we concentrate on AddWindowsPrinterConnection.
Pre-requisites for Mapping Printers
- You need a machine with a shared printer.
Instructions for a simple Printer Logon Script - Copy and paste the script below into notepad.
- Change the server name from "\\alan to the name of your print server.
- Save the file with .vbs extension e.g. Printers.vbs.
- Double click the VBScript and then launch your Printers and Faxes folder. There should be a new printer icon.
' ' Printers.vbs - Windows Logon Script. Set objNetwork = CreateObject("WScript.Network") objNetwork.AddWindowsPrinterConnection "\\alan\Epson."
Learning Points
Note 1: I do realize that scripts go wrong. However, with printer scripts, its often the result of 'over think', so begin with simple techniques, ideas and syntax. For instance, this
basic script needs no commas. Note 2: This script conforms to the classic VBScript structure, object, method, and value. We create objNetwork, apply the AddWindowsPrinterConnection method and
assign the value of your shared network printer.
Note 3: There are more comprehensive printer examples here
Mapping Printers is a classic job for a Windows logon script. Take the time to understand the print terminology, then go ahead an copy my scripts and amend them to your circumstances. Along
the journey, take the time to learn more about VBScript objects and particularly methods, for example, AddWindowsPrinterConnection and SetDefaultPrinter.
|