Problem listing services with wmi
Jean-Sébastien Guay
jean_seb at videotron.ca
Tue May 17 13:21:11 EDT 2005
Hi again Tim,
>Well I honestly don't know if this will go any further,
>but the following code uses the win32service module from
>pywin32 to collect the service information, on the off-chance
>that it *won't* fail where WMI does. I can't easily test it
>since the script doesn't raise an error on my machine.
>
>
Seems like your hunch was right, the first loop completes correctly.
Adding a counter to both loops shows that getting services from
win32service.EnumServicesStatus() gets 108 services, and getting them
through WMI gets to 87 and then halts with the previously mentioned error :
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "G:\Python-2.4\Lib\site-packages\win32com\client\util.py", line
83, in next
return _get_good_object_(self._iter_.next())
pywintypes.com_error: (-2147217398, 'OLE error 0x8004100a', None, None)
From examining your code I imagine you tried to catch the exception,
but it didn't work because the exception is thrown on the "for" line and
not when getting the service's Caption property... So it stopped at 87
anyways. And indeed, the "only in win32" list shows 21 entries (
len(win32_names - wmi_names) = 108-87 = 21 ).
[...snip code...]
># Not sure if you're running 2.3/2.4
>
>
Python 2.4 on Windows XP SP2 here.
Do you think we're getting anywhere with this? If not, then I'll just
use the "win32" method of getting the service list, even though it isn't
as pretty. I don't want to waste your time on something that may have
more to do with my machine than anything else... But if you want to try
and get to the bottom of this, I have no problem with trying out other
suggestions.
Thanks a lot, just by your small scripts I've already learned a lot more
about Python!
J-S
--
___________________________________________
Jean-Sébastien Guay jean_seb at videotron.ca
http://whitestar02.webhop.org/
More information about the Python-list
mailing list