How can I use a Windows Management Instrumentation (WMI) script to list printers?

A. I created the following script, which you can download here , that makes a WMI call and lists details about the printers known on the system:

Option Explicit
Dim objWMIService, objPrinter, colItems, strComputer

strComputer ="."

Set objWMIService = GetObject("winmgmts:\\" & strComputer & 
Set colItems = objWMIService.ExecQuery ("SELECT * FROM Win32_Printer")

' On Error Resume Next
For Each objPrinter In colItems
   Wscript.Echo "DeviceID: " & objPrinter.DeviceID 
   Wscript.Echo "Caption: " & objPrinter.Caption 
   Wscript.Echo "ServerName: " & objPrinter.ServerName 
   Wscript.Echo "ShareName: " & objPrinter.ShareName 
   Wscript.Echo "DriverName: " & objPrinter.DriverName 
   Wscript.Echo "Default: " & objPrinter.Default

Here's an example of the script's output.
DeviceID: Tektronix Phaser 850DP
Caption: Tektronix Phaser 850DP
ShareName: ColorPrinter
DriverName: Tektronix Phaser 850DP
Default: True
DeviceID: Microsoft Office Document Image Writer
Caption: Microsoft Office Document Image Writer
ShareName: Printer2
DriverName: Microsoft Office Document Image Writer Driver
Default: False
DeviceID: Adobe PDF
Caption: Adobe PDF
ShareName: Printer3
DriverName: Adobe PDF Converter
Default: False
DeviceID: \\\CWIS
Caption: \\\CWIS
ServerName: \\
ShareName: CWIS
DriverName: Xerox DocuPrint N2125 PS
Default: False
Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.