VBS Script To Retrieve The Current Status Of A Specified Printer Share

 

This VBS script will retrieve the printer status for a hard coded print server name. To prompt for a Printer name replace the line that reads: strPrinterShare = "HPPSC160"

with strPrinterShare = InputBox("Enter Printer Share Name")

 

VBS Script:

 

strComputer = InputBox("Enter Print Server Name")

strPrinterShare = InputBox ("Enter Printer Share Name")

strPrinterShare = "HPPSC160"

 

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_Printer Where ShareName = '" & strPrinterShare & "'")

 

For Each objItem in colItems

Select Case objItem.DetectedErrorState

Case 0 Status = "On line"

Case 1 Status = "Paused"

Case 2 Status = "Pending Deletion"

Case 3 Status = "Error"

Case 4 Status = "Paper Jam"

Case 5 Status = "Paper Out"

Case 6 Status = "Manual Feed"

Case 7 Status = "Paper Problem"

Case 8 Status = "Offline"

Case 256 Status = "IO Active"

Case 512 Status = "Busy"

Case 1024 Status = "Printing"

Case 2048 Status = "Output Bin Full"

Case 4096 Status = "Not Available"

Case 8192 Status = "Waiting"

Case 6384 Status = "Processing"

Case 32768 Status = "Initializing"

Case 65536 Status = "Warming Up"

Case 131072 Status = "Toner Low"

Case 262144 Status = "No Toner"

Case 524288 Status = "Page Punt"

Case 1048576 Status = "User Intervention"

Case 2097152 Status = "Out of Memory"

Case 4194304 Status = "Door Open"

Case 8388608 Status = "Server Unknown"

Case 16777216 Status = "Power Save"

Case Else Status = "UNKNOWN"

End Select

 

If Err.Number = 0 Then

MsgBox objItem.ShareName & " (" & objItem.Name &") "  & "Is: " & Status

Else

MsgBox "The Account: " & UCase(strLogonName) & " Was Not Found"

End If

Next

 

 

 

Published Sunday, August 17, 2008 3:30 PM by dhite
Filed under:

Comments

No Comments