Specifications

Appendix B
WMI Script to get Basic Status
B-8
P1028248-001 Rev. A KR203 Software Integrator Guide 8/6/2010
WMI Script to get Basic Status
' VBScript source code
ttpname=""
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" &
strComputer & "\root\cimv2")
Set wbemObjectSet = objWMIService.ExecQuery("SELECT *
FROM Win32_Printer")
For Each wbemObject In wbemObjectSet
if wbemObject.Default = TRUE then
ttpname = wbemObject.Caption
Wscript.Echo "Printer " & ttpname
Select Case wbemObject.PrinterStatus
Case 1
strPrinterStatus = "Other"
strExtendedPrinterStatus =
wbemObject.ExtendedPrinterStatus
Case 2
strPrinterStatus = "Unknown"
Case 3
strPrinterStatus = "Idle"
Case 4
strPrinterStatus = "Printing"
Case 5
strPrinterStatus = "Warmup"
Case 6
strPrinterStatus = "Stopped printing"
Case 7
strPrinterStatus = "Offline"
End Select
Wscript.Echo "Printer Status: " & strPrinterStatus
Select Case wbemObject.DetectedErrorState
Case 0
Wscript.Echo "DetectedErrorState: " &
wbemObject.DetectedErrorState & " Unknown"
case 1
Wscript.Echo "DetectedErrorState: " &
wbemObject.DetectedErrorState & " Other"
case 2