Printer status and monitoring (WMI , SNMP)

G

Guest

I'm using VB.NET 2005 (with a little c#)

Before printing a document my app need to know if the printer
is functioning. A paper jam, low on toner etc could have knocked
the printer out. I'm trying two approached to this: WMI and SNMP.
(BTW the printer is attached using its network interface. )

WMI
I can get the PrinterStatus (and ExteandedPrinterStatus) I think WMI
is working at the print spooler level. If I turn the printer off WMI still
reports status 3 (OK) when clearly the printer is unavailble, but ot
course the printer spooler system does not know this until a print
is attempted. If I then print a test page, after 30 seconds the spooler
gives up. At this point WMI will report status 1.

If I pull the paper tray on the printer so its "out of paper" and print
the following happends. WMI status goes to 4 (printing) while
print job briefly shows in queue then returns to 3. I guess
WMI is quite corrent, the print job has been sent to the print
which has placed it in its own internal queue awaiting more paper.

The upshot of this, I think, is that I'll have to talk firectly to the printer
hence my trip to SNMP land.

SNMP
Last month experimenting with another printer I got as far as
finding a Status field amoungst hunderds of other fields. It seemed
to be updated in a timely manner. To get that far I had to download
a trial version of a SNMP manager program and to find a MIB file
for the printer.

Today I've been examining a c# SNMP class (from www.c-sharpcorner.com) and
trying to find a MIB suitable for an HP 2605DN printer.

Questions:
1. Is SNMP the way to go ?
2. Do I need a MIB for the HP or is there some standard MIB
3. What would be the simplest means for my app to talk the
the SNMP agent(HP printer) the c# class is throwing exceptions.

As usual I don't have much time to look deeply into these areas.

M.
 
L

Linda Liu [MSFT]

Hi M,

Based on my understanding, you'd like to detect the printer's status before
you print a document. If I'm off base, please feel free to let me know.

I am not SNMP expert, so I couldn't give you any assistance on SNMP.

The status of printers and print jobs are updated by the Win32 Spooler
during the despool of a print job. All other time, when that printer is not
despooling and resports no state information, the printer is considered to
be ready and idle. It means that if there's no print job in the print
queue, we have no way to get the real status of the physical printer.

To determine the state of a physical printer, there is one fundamental
premise that must be true: the Spooler must be attempting to send a print
job to the physical printer. This is the only time the state of the printer
is reported by the port monitor. In addition, the most meaningful
information may be reported in the status members of a JOB_INFO structure
for that particular print job because some port monitor will have set these
values directly.

For more information on how to get the status of a printer and a print job,
you may visit the following KB article.

'How to get the status of a printer and a print job'
http://support.microsoft.com/kb/160129/en-us

Hope this helps.
If you have any question, please feel free to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

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

Guest

Hi

I don't want to attempt a print and have it fail, so a status query on the
spooler
is ruled out. MS provide a SNMP API and a way for SNMP to become a feeder
to the WMI system but both these approaches take some setting up, so
they're ruled out.

What I found eventually is http://www.codeproject.com/useritems/SNMPDLL.asp

Make a reference to SNMPDll and TableReader.
Imports SNMPDll
Imports Org.Snmp
agent = New SNMPAgent("192.168.1.65")
snmp = New SNMPObject("1.3.6.1.2.1.25.3.5.1.1.1")
Me.btnCheckPrinter.Text = snmp.getSimpleValue(agent)

192.168.165 is the adress of the printer.
1.3.6.1.2.1.25.3.5.1.1.1 is the OID for the printer status. I found this by
browsing the printer with a SNMP manager program.

And that's it. Now I know instantly what state the printer is in.

M.
 
L

Linda Liu [MSFT]

Hi M,

Thank you for your feedback on how you succeed in solving this problem
using SNMP.

I think it will definitely benefit other readers in the newsgroup.

If you have any other questions in the future, please don't hesitate to
contact us.

Have a nice day!

Sincerely,
Linda Liu
Microsoft Online Community Support
 

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

Similar Threads

SNMP not allowed 1
Regarding SNMP update request Interval in Windows Printing 0
WMI, SNMP and MIBs 0
SNMP 1
SNMP query printerstatus 2
Printer purchase help and advice 10
Epson Printer Problem 6
SNMP monitoring 1

Top