[python-win32] How to enumerate a WMI object to discover its properties?

Tim Golden mail at timgolden.me.uk
Thu Mar 4 09:49:28 CET 2010


On 04/03/2010 06:38, python at bdurham.com wrote:
> Is there a way to enumerate a WMI object's properties to discover
> what they are vs. having to explictly reference properties by
> name?

Assuming I understand the question, a quickie shortcut is
just to "print" the object:

<code>
import wmi

c = wmi.WMI ()
for s in c.Win32_ComputerSystem ():
   print s

</code>

but in fact each object also holds a list of its own properties:

<code>
import wmi

c = wmi.WMI ()
print list (c.Win32_ComputerSystem.properties)
print list (c.Win32_ComputerSystem.methods)

or you can do the same with an instance:

for s in c.Win32_ComputerSystem ():
   print list (s.properties)

</code>

TJG


More information about the python-win32 mailing list