WMI in Python

alex23 wuwei23 at gmail.com
Thu Sep 16 04:01:07 CEST 2010

KING LABS <kinglabs... at gmail.com> wrote:
> The following information is exactly what I am trying to collect for
> the inventory. I can find vb scripts with googling. I want to do the
> same with Python & Win32. Use Server/Client architecture .
> Client(agent) updates the information to server.

I highly agree with the recommendations for Tim Golden's WMI library.
I once used it during an MS VBScript course for sys admins to produce
python equivalents of the VBS code; it was far, _far_ easier to
componentise & reuse python code than VBS.

However, for a quick & ready solution, have you looked at Microsoft's
Scriptomatic?[2] It's a handy little tool that lets you specify the
WMI query you want and produces code for you, with Python being one of
the targets. It _should_ be able to handle most of everything you're
after, with the exception of Software Information (from memory that's
not something WMI covers?).

Once Scriptomatic has generated the bulk of the WMI code, that's the
payload of your client-side script. There are many many many ways of
doing simple client/server set ups in python, just google and pick one
that works at a suitable abstraction level for you. Here's a
straightforward sockets-based approach[3] (that I've never used but
looks okay).

1: http://timgolden.me.uk/python/wmi/index.html
2: http://www.microsoft.com/downloads/en/details.aspx?FamilyID=09dfc342-648b-4119-b7eb-783b0f7d1178&displaylang=en
3: http://wdvl.internet.com/Authoring/python/client/watts06152009.html

More information about the Python-list mailing list