'========================================================================== ' ' ' NAME: ' ' AUTHOR: Ed Wilson , MS ' DATE : 8/1/2006 ' ver.2.0 modified to include function for status ' COMMENT: '1. Use of win32_Printer to monitor printers '2. Use of the WMI moniker '3. Use of for each next to iterate a collection '4. Use of select case to present useful status info '========================================================================== Option Explicit On Error Resume Next Dim strComputer Dim wmiNS Dim wmiQuery Dim objWMIService Dim colItems Dim objItem strComputer = "." wmiNS = "\root\cimv2" wmiQuery = "Select * from win32_Printer" Set objWMIService = GetObject("winmgmts:\\" _ & strComputer & wmiNS) Set colItems = objWMIService.ExecQuery(wmiQuery) For Each objItem in colItems WScript.Echo "Name: " & objItem.Name WScript.Echo "Location: " & objItem.Location WScript.Echo "Printer Status: " & funEvalStatus(objItem.PrinterStatus) WScript.Echo "Server Name: " & objItem.ServerName WScript.Echo "Share Name: " & objItem.ShareName WScript.Echo Next Function funEvalStatus(intIN) Select Case intIN Case 1 funEvalStatus = "Other" Case 2 funEvalStatus = "Unknown" Case 3 funEvalStatus = "Idle" Case 4 funEvalStatus = "Printing" Case 5 funEvalStatus = "Warmup" Case 6 funEvalStatus = "Stopped Printing" Case 7 funEvalStatus = "Offline" End Select End Function