Printing Overview

Microsoft® Windows® 2000 Scripting Guide

Print management is one of the most time-consuming of all system administration tasks in an enterprise. This is due to a number of factors:

  • In large organizations, the number of pages printed each day might number in the tens of thousands. In addition, these print jobs take place on multiple printers located throughout the enterprise, complicating the logistics involved in monitoring and managing these devices.

  • Printers, unlike many other peripheral devices, require daily maintenance: replenishing the paper trays, installing new toner cartridges, and carrying out other maintenance activities. Printers can also encounter problems, such as paper jams, that require a visit from a service technician.

  • Unlike other services, the print service is typically engaged all day long, even during the so-called off hours. Administrators often schedule large print jobs to take place when most users have left for the day. As a result, the printers are continually busy, even when few users are physically present in the building.

  • When a printer breaks down, a domino effect can occur. If not immediately fixed, this breakdown can create a huge backlog of stalled print jobs. This can place an enormous burden on Help desk personnel, who must not only fix the problem but also deal with user complaints and questions.

In addition to these challenges, print management has traditionally been carried out on a printer-by-printer basis and has required administrators to rely on the graphical user interface (GUI) to monitor printer status and modify printer configurations. While this approach is adequate in small organizations, it is far less effective in organizations with hundreds of printers, many at remote sites.

Microsoft® Windows® 2000 provides a number of scripting tools for managing printers, print queues, print jobs, and printer drivers. Enhancements to the Windows Management Instrumentation (WMI) and Active Directory Service Interfaces (ADSI) scripting technologies make it possible for administrators to write scripts that can automate much of the print management process.

Note

  • There are times when WMI and ADSI offer similar functionality for managing printers, print queues, or print jobs. When the functionality overlaps, the WMI method is demonstrated. This is because WMI is the preferred method for managing computers, while ADSI is the preferred method for managing directory service objects. ADSI scripts are used only when there is no WMI equivalent.

Working with Multiple Printers

In large organizations, a single print server is likely to be responsible for scores of printers. Accessing all the printers managed by a print server, or all the print jobs currently in print queues on that print server, is easy when using WMI. By default, WMI retrieves collections consisting of multiple printers or print jobs; for example, the following query returns a collection consisting of all the printers managed by a print server:

SELECT * FROM Win32_Printer

If you want to access only a single printer, you need to include the printer name as part of your query:

SELECT * FROM Win32_Printer WHERE Name = 'ArtDepartmentPrinter'

ADSI, by comparison, requires you to individually bind to each printer on a print server. For example, to bind to the printer named ArtDepartmentPrinter on the print server atl-ps-01, you would use a code statement similar to the following:

Set objPrinter = GetObject("WinNT://atl-ps-01/ArtDepartmentprinter")

However, it is still possible to return a collection of all the printers on a print server, and without knowing the names of those printers. To do this, a script must:

  1. Connect to the print server and return a list of all objects on that server.

  2. Use an ADSI filter to limit the working data set to printQueue items.

  3. For each printQueue item, use a GetObject call and the ADsPath property to individually bind to the printer.

For example, the script in Listing 13.1 returns a list of all the printers managed by the print server atl-ps-01, individually binds to each printer, and then echoes the printer name.

Listing 13.1 Using ADSI to Enumerate All the Printers on a Print Server

  
1
2
3
4
5
6
Set objComputer = GetObject("WinNT://atl-win2k-01,computer")
objComputer.Filter = Array("printQueue")
For Each objPrinter In objComputer
 Set objPrintQueue = GetObject(objPrinter.ADsPath)
 Wscript.Echo objPrintQueue.Name
Next

For educational purposes, the scripts in this chapter typically use ADSI to bind to a single printer on a print server. However, you can use the code shown in Listing 13.1 to modify those scripts and thus work with all the printers managed by a print server.

The terminology used when discussing printing with Windows 2000-based systems sometimes differs from the terminology used when discussing printing in regular conversation. Table 13.1 lists some of the key terms, along with a brief definition of each term as it is used in this chapter.

Table 13.1 Print Terminology

Term

Definition

Print device

Also referred to as the physical printer, the print device is the physical device that produces printed pages. In Windows 2000, the term printer specifically refers to the logical printer, the software interface between a print device and the computers submitting documents for printing.

In this chapter, the term print device is used only when there is possible confusion between the logical printer and the physical printer. Most of the time, the term printer or physical printer is used instead.

Printer

Also referred to as a logical printer, this is the software interface between a print device and computers submitting documents for printing.

Print server

The computer responsible for managing the print queues for a printer or group of printers. In a large organization, a single computer might manage 200 or more printers.

Printer driver

The software that allows applications to communicate with specific printers. Printer drivers translate print commands sent to a computer into the print language understood by a particular printer. Because printers vary in their capabilities and print language, separate printer drivers might be needed for each printer installed on a computer.

Print job

Any document sent to a printer. Print jobs are assigned both a unique job ID and a priority (0-99). Higher-priority jobs are printed before lower-priority jobs.

Print queue

The collection of print jobs waiting to be printed by a specified printer.

Printer port

The interface through which the logical printer communicates with the physical printer. For physical printers directly attached to computers, the port will typically be a parallel port such as LPT1 or a Universal Serial Bus (USB) port. For printers directly attached to the network (that is, using their own network adapter), the port will typically be a TCP/IP port.

Printers can be attached directly to a print server using a local printer port. However, local ports such as LPT1 are much slower than TCP/IP printer ports.

Print spooler

Software that accepts a document sent to a printer and then stores it on disk or in memory until the printer is ready for it. The spooler receives, processes, schedules, and distributes documents for printing.

In Windows 2000, spooling is carried out by the Print Spooler service (usually called the print service). If this service is stopped, you cannot print until the service has restarted.