[python-win32] problem getting printer status in Windows
mail at timgolden.me.uk
Tue Apr 21 12:19:06 CEST 2009
Alec Bennett wrote:
> I'm having trouble getting the printer status in Windows.
> Ideally I'd like to get the info contained in the "Status" column
> when you open a printer from the Windows control panel --> printers.
Generally, altho' not always, questions like this have an answer
which starts with "WMI". In this case I'm not absolutely convinced,
but it looks quite good. Guessing that the Win32_Printer class is
what you want leads to this:
and the PrinterStatus or ExtendedPrinterStatus attributes which
looks handy. So...
c = wmi.WMI ()
for p in c.Win32_Printer ():
print p.Caption, p.Printerstatus
Frankly I've no idea if it's any more or less reliable than your
other method; maybe someone who's done more printer-related work
can chip in here. But it at least opens an alternative avenue
for you to look at.
More information about the python-win32