Is WMI PrinterStatus in WIN32_Printer reliable?

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.
 
A

Alan Morris [MSFT]

If the Dell software probably bypasses the spooler to get status or they do
not report the status to the spooler process,. the win32 print provider will
report whatever status the spooler contains. If the spooler reports Ready,
it never gets data with a status change (default is ready) and the provider
just exports this as Idle.

--
Alan Morris
Windows Printing Team
Search the Microsoft Knowledge Base here:
http://support.microsoft.com/default.aspx?scid=fh;[ln];kbhowto

This posting is provided "AS IS" with no warranties, and confers no rights.
 
F

F. C.

Thanks, Alan. So it all depends whether a printer(or its
software/driver/language monitor) reports its status back to spooler or not.
The spooler's printer status is what we get from the "PrinterStatus" of
Win32_printer.

I'm writing this printer monitoring program intend to monitor large
commercial printers with built-in network card (Epson C8600/c8500 for
example).
For example, auto-send an email if "Low Toner", "Service Requested" found in
"DetectedErrorState".

Does anyone know if most of those commercial printer reports its status back
to spooler or not? (don't have those commercial machines for me to test for
now :)

I guess if those commercial machines don't report status back to spooler, I
will need to write monitoring program to be specific on different printers.
In that case, anyone has experience on how to get started? (need to get
different interface/API that each printer vender provides, I guess)

Thanks.



Alan Morris said:
If the Dell software probably bypasses the spooler to get status or they
do not report the status to the spooler process,. the win32 print provider
will report whatever status the spooler contains. If the spooler reports
Ready, it never gets data with a status change (default is ready) and the
provider just exports this as Idle.

--
Alan Morris
Windows Printing Team
Search the Microsoft Knowledge Base here:
http://support.microsoft.com/default.aspx?scid=fh;[ln];kbhowto

This posting is provided "AS IS" with no warranties, and confers no
rights.

F. C. said:
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.
 
S

Sam Hobbs

Yes I am nearly certain that you won't find a printer driver provided by
Windows that can get status data from printers. Older printers do not
provide any data from them and the Windows printer device drivers were
designed without any consideration for data being sent back. As far as I
know (I am not in touch with the current technology though) the printer
device drivers have not been redesigned.

A printer device driver is actually two device drivers; the main device
driver just produces output that can be stored temporarily in disk files by
the spooler. Then that data is sent to the printer using a device driver
appropriate for the connection, since the connection can be parrallel or
serial or something else. The printer reports status using physical wires
that send only on/off or error/okay status; in other words, the physical
wires are extremely limited.


F. C. said:
Thanks, Alan. So it all depends whether a printer(or its
software/driver/language monitor) reports its status back to spooler or
not. The spooler's printer status is what we get from the "PrinterStatus"
of Win32_printer.

I'm writing this printer monitoring program intend to monitor large
commercial printers with built-in network card (Epson C8600/c8500 for
example).
For example, auto-send an email if "Low Toner", "Service Requested" found
in "DetectedErrorState".

Does anyone know if most of those commercial printer reports its status
back to spooler or not? (don't have those commercial machines for me to
test for now :)

I guess if those commercial machines don't report status back to spooler,
I will need to write monitoring program to be specific on different
printers. In that case, anyone has experience on how to get started?
(need to get different interface/API that each printer vender provides, I
guess)

Thanks.



Alan Morris said:
If the Dell software probably bypasses the spooler to get status or they
do not report the status to the spooler process,. the win32 print
provider will report whatever status the spooler contains. If the
spooler reports Ready, it never gets data with a status change (default
is ready) and the provider just exports this as Idle.

--
Alan Morris
Windows Printing Team
Search the Microsoft Knowledge Base here:
http://support.microsoft.com/default.aspx?scid=fh;[ln];kbhowto

This posting is provided "AS IS" with no warranties, and confers no
rights.

F. C. said:
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.
 
W

Willy Denoyette [MVP]

Sam is right to the point, what you need is a printer driver that gets the
status from the printer and reports the status to WMI. While most high end
printer divers do the first, not all of them are WMI compliantand use a
private interface to support monitoring utilities.
These utilities are in general distibuted with the printer software (
drivers etc...).
IMO, it's best to consult Epson.

Willy.

| Thanks, Alan. So it all depends whether a printer(or its
| software/driver/language monitor) reports its status back to spooler or
not.
| The spooler's printer status is what we get from the "PrinterStatus" of
| Win32_printer.
|
| I'm writing this printer monitoring program intend to monitor large
| commercial printers with built-in network card (Epson C8600/c8500 for
| example).
| For example, auto-send an email if "Low Toner", "Service Requested" found
in
| "DetectedErrorState".
|
| Does anyone know if most of those commercial printer reports its status
back
| to spooler or not? (don't have those commercial machines for me to test
for
| now :)
|
| I guess if those commercial machines don't report status back to spooler,
I
| will need to write monitoring program to be specific on different
printers.
| In that case, anyone has experience on how to get started? (need to get
| different interface/API that each printer vender provides, I guess)
|
| Thanks.
|
|
|
| | > If the Dell software probably bypasses the spooler to get status or they
| > do not report the status to the spooler process,. the win32 print
provider
| > will report whatever status the spooler contains. If the spooler
reports
| > Ready, it never gets data with a status change (default is ready) and
the
| > provider just exports this as Idle.
| >
| > --
| > Alan Morris
| > Windows Printing Team
| > Search the Microsoft Knowledge Base here:
| > http://support.microsoft.com/default.aspx?scid=fh;[ln];kbhowto
| >
| > This posting is provided "AS IS" with no warranties, and confers no
| > rights.
| >
| > | >> 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.
| >>
| >>
| >>
| >>
| >>
| >
| >
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top