Sunday, 15 May 2011

getting iis worker processes from wmi in python -



getting iis worker processes from wmi in python -

i'm trying dispay process if , pool names of iis in python. here python code:

import wmi c = wmi.wmi('.', namespace="root/webadministration") c.query("select processid workerprocess")

it fails:

traceback (most recent phone call last): file "<stdin>", line 1, in <module> file "c:\python27\lib\site-packages\wmi.py", line 1009, in query homecoming [ _wmi_object (obj, instance_of, fields) obj in self._raw_query(wql) ] file "c:\python27\lib\site-packages\win32com\client\util.py", line 84, in next homecoming _get_good_object_(self._iter_.next(), resultclsid = self.resultclsid) pywintypes.com_error: (-2147217389, 'ole error 0x80041013', none, none)

i tried:

for p in c.workerprocess: print p.processid

which not work either. here similar visualbasic script code works fine:

set owebadmin = getobject("winmgmts:root\webadministration") set processes = owebadmin.instancesof("workerprocess") each w in processes wscript.echo w.processid wscript.echo w.apppoolname next

the documentation is: http://msdn.microsoft.com/en-us/library/microsoft.web.administration.workerprocess(v=vs.90).aspx

it looks i'm supposed instantiate cannot figure out how. ideas how work in python?

actually code correct. needed run admin preivileges.

python wmi

No comments:

Post a Comment