[python-win32] Python WMI SCript to get installed software

Tim Roberts timr at probo.com
Wed Jul 25 20:41:27 CEST 2012


Carlos Hotmail wrote:
> Hi all on the list.
>  
> The following question is regarding an error that raises when i try to
> execute this script:
> import _winreg
> import wmi
>
> r = wmi.Registry ()
> result, names = r.EnumKey (
>   hDefKey=_winreg.HKEY_LOCAL_MACHINE,
>   sSubKeyName="Software"
> )
> for key in names:
>   print key
> ...
> and this is the error message it give me:
> x_wmi: <x_wmi: Unexpected COM Error (-2147352567, 'Ocurri\xf3 una
> excepci\xf3n.', (0, u'SWbemProperty', u'Los tipos no coinciden ',
> None, 0, -2147217403), None)>

Is that EXACTLY your code?  Because I typed that code into my XP machine
exactly as you have it, and it worked just fine.  -2147217403 is
0x80041005, which is WBEM_E_TYPE_MISMATCH (which is probably what "Los
tipos no coinciden" means..).


> what i’m trying to do is to get the installed software on the machine,
> but not with the Win32_Product, because the list it posts seems
> incomplete, not all the installed software is on that list.

The Software key of the registry is not the right way to do that. 
Firstly, that usually has company names, not product names.  Secondly,
it's entirely up to the app whether they need a registry key or not. 
Some do, some don't.

In actual fact, there simply is no central repository of installed
software on a Windows machine.  You can go enumerate the uninstall list,
but that only works if the application created an uninstaller.

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the python-win32 mailing list