[python-win32] Fwd: Using Python and WMI for multiple machines
Graeme Glass
graemeglass at gmail.com
Thu Feb 21 07:35:22 CET 2008
<code - untested>
> import wmi
> >
> > servers = open ("c:/servernames.txt").read ().splitlines ()
> > for server in servers:
> > wmi_connection = wmi.WMI (server)
> > with open ("%s-services.log" % server, "w") as f:
> > for service in wmi_connection.Win32_Service ():
> > f.write ("%s\t%s\n" % (service.Caption, service.State))
> >
> > </code>
> >
> > HTH
> > TJG
> > _______________________________________________
> > python-win32 mailing list
> > python-win32 at python.org
> > http://mail.python.org/mailman/listinfo/python-win32
> >
>
> Note that the above code will only work under Python 2.5, since that's
> when the "with" statement was added.
>
> (Some of us are still stuck in 2.4 land :) )
>
>
If I am not mistaken, you can use the with statement with python 2.4
from __future__ import with_statement
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-win32/attachments/20080221/fbf7a380/attachment.htm
More information about the python-win32
mailing list