O'Reilly logo

Microsoft® Windows® Scripting Self-Paced Learning Guide by Ed Wilson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Obtaining the Status of Printers

In your first printer management script, you’ll use the Win32_Printer WMI class to obtain information about the status of printers defined on a computer. This particular script runs on Microsoft Windows Server 2003 and on Windows XP, so it can run on a server to obtain the status of all the printers defined, or it can run as a diagnostic tool on a workstation. The MonitorPrinterStatus.vbs follows:

Option Explicit 'On Error Resume Next Dim strComputer Dim wmiNS Dim wmiQuery Dim objWMIService Dim colItems Dim objItem Dim strStatus strComputer = "." wmiNS = "\root\cimv2" wmiQuery = "Select * from Win32_Printer" Set objWMIService = GetObject("winmgmts:\\" _ & strComputer & wmiNS) Set colItems = objWMIService.ExecQuery(wmiQuery) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required