Получение информации о состоянии принтеров

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)

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Location: " & objItem.Location
subEvalStatus
    Wscript.Echo "Printer Status: " & strStatus
    Wscript.Echo "Server Name: " & objItem.ServerName
    Wscript.Echo "Share Name: " & objItem.ShareName
    Wscript.Echo
Next

Sub subEvalStatus
Select Case objItem.PrinterStatus
        Case 1
            strStatus = "Other"
        Case 2
            strStatus = "Unknown"
        Case 3
            strStatus = "Idle"
        Case 4
            strStatus = "Printing"
        Case 5
            strStatus = "Warmup"
        Case 6
        	strStatus = "Stopped Printing"
        Case 7
        	strStatus = "Offline"
    End Select
End Sub
Интересное на сайте: 
0
Голосов пока нет

Оставить комментарий