Re: Problem listing services with wmi



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@xxxxxxxxxxxx
            http://whitestar02.webhop.org/

.



Relevant Pages

  • Re: WMI GetObject Failing to return anything
    ... gave an access denied and would just fail without any error. ... I have the script ping each ... >> first to make sure it returns as alive before I attempt a WMI call to ... >> error message that is generated by GetObject. ...
    (microsoft.public.windowsxp.wmi)
  • Re: Windows Script
    ... I tried your script, and this code does not fail ... If you like to be inspired a bit more to WMI please see: ... the NT Event Log on http://www.wbem.dk/Root/CIMV2/Win32_NTLogEvent.asp ...
    (microsoft.public.isaserver)
  • RE: Does WMI have to be installed on Remote Computer?
    ... IMHO this looks like a well constructed and very vell commented script. ... WMI comes as standard on w2k w2k3 and xp, ... does WMI need to be installed on the remote computer in order for a ... ''' First try to ping the server. ...
    (microsoft.public.scripting.vbscript)
  • Re: Look over this script.....could anything be done better?
    ... will be unable to connect with WMI. ... With this version of the script I have kept that included because the script that enumerates all of the servers has some servers that no longer exist. ... Dim objWMIService, colFixedDrives, objFD ...
    (microsoft.public.scripting.vbscript)
  • Re: Benefits of Dynamic Typing
    ... The latter problem is detected in parts not specific to the compiler, ... and the only information about the reason is carried by the exception ... the entire Map call fails with the same exception. ... but it did expect that some application might fail. ...
    (comp.lang.functional)