F
F. C.
I'm using WMI to get PrinterStatus from WIN32_printer.
An simple script like this returns all printer status in a machine -
=============
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colInstalledPrinters = objWMIService.ExecQuery _
("Select * from Win32_Printer")
For Each objPrinter in colInstalledPrinters
Wscript.Echo "Name: " & objPrinter.Name
Wscript.Echo "Location: " & objPrinter.Location
Select Case objPrinter.PrinterStatus
Case 1
strPrinterStatus = "Other"
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
Wscript.Echo "Server Name: " & objPrinter.ServerName
Wscript.Echo "Share Name: " & objPrinter.ShareName
Wscript.Echo
Next
======
However, why it gets all printer status as "Idle" as in fact they are
off-line (power-off)?
For the Dell A940 bi-directional communication printer I'm using, Dell's
printer software can detect its status and show something like "printer is
off", "cover open"...etc.
However, running the script about on the XP machine the printer connects to,
it always shows "Idle".
Just like status "Ready" in printer and fax status from control panel while
it should show "offline" or something else.
I think I miss something here. Can anyone point out?
Thanks.
An simple script like this returns all printer status in a machine -
=============
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colInstalledPrinters = objWMIService.ExecQuery _
("Select * from Win32_Printer")
For Each objPrinter in colInstalledPrinters
Wscript.Echo "Name: " & objPrinter.Name
Wscript.Echo "Location: " & objPrinter.Location
Select Case objPrinter.PrinterStatus
Case 1
strPrinterStatus = "Other"
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
Wscript.Echo "Server Name: " & objPrinter.ServerName
Wscript.Echo "Share Name: " & objPrinter.ShareName
Wscript.Echo
Next
======
However, why it gets all printer status as "Idle" as in fact they are
off-line (power-off)?
For the Dell A940 bi-directional communication printer I'm using, Dell's
printer software can detect its status and show something like "printer is
off", "cover open"...etc.
However, running the script about on the XP machine the printer connects to,
it always shows "Idle".
Just like status "Ready" in printer and fax status from control panel while
it should show "offline" or something else.
I think I miss something here. Can anyone point out?
Thanks.