Microsoft® Windows® 2000 Scripting Guide
« Previous | Next »
The best way to minimize the impact of a printer that is no longer working or accessible is to identify the problem and restore the printer functionality as quickly as possible. Even if this functionality cannot be restored (for example, the printer might have experienced a hardware problem that you are unable to repair), it is still important that printer problems be identified as quickly as possible; at the very least, this allows you to notify users that they should reroute their documents and not print anything to the "broken" printer.
You can use the Win32_Printer class to retrieve a status report for all the printers managed by a given print server.
Listing 13.2 contains a script that monitors the status of all the printers on a computer. To carry out this task, the script must perform the following steps:
This query returns a collection consisting of all the printers installed on the computer.
Because printer status is returned as an integer, a series of Select Case statements is used to convert the integer to a recognizable text string. For example, if PrinterStatus is 4, the value "Printing" is echoed to the screen.
Listing 13.2 Monitoring the Status of All the Printers on a Computer
|
|
Send us your feedback | « Previous | Next » |