[python-win32] get installed software remote machine

pacopyc pacopyc at gmail.com
Tue Apr 27 10:36:13 CEST 2010


Ok, thank you very much. Very good with set administrator password (it works), but I've problem with installed software. The list is not complete (I don't understand). For example key "Adobe Flash Player ActiveX" return this error:

Traceback (most recent call last):
  File "<pyshell#49>", line 1, in <module>
    key = OpenKey(HKEY_LOCAL_MACHINE,
'Software\Microsoft\Windows\CurrentVersion\Uninstall\Adobe Flash Player ActiveX', 0, KEY_ALL_ACCESS)
WindowsError: [Error 2] Impossibile trovare il file specificato (Impossible find file)

But key "Software\Microsoft\Windows\CurrentVersion\Uninstall\Adobe Flash Player ActiveX" exists.
What's the problem? The spaces? I don't think so.

This is the code:

import wmi
from _winreg import (HKEY_LOCAL_MACHINE, KEY_ALL_ACCESS, OpenKey, EnumValue, QueryValueEx)

host='XXXX'
reg = wmi.WMI(host,namespace="root/default").StdRegProv
result, names = reg.EnumKey (hDefKey=HKEY_LOCAL_MACHINE,sSubKeyName=r"Software\Microsoft\Windows\CurrentVersion\Uninstall")
keyPath = r"Software\Microsoft\Windows\CurrentVersion\Uninstall"
count = 0
while count <= len(names):
    try:
        print names[count]
        path = keyPath + "\\" + names[count]
        key = OpenKey(HKEY_LOCAL_MACHINE, path, 0, KEY_ALL_ACCESS)
        temp = QueryValueEx(key, 'DisplayName')
        display = str(temp[0])
        print names[count]+" -> "+display
        count += 1
    except:
        count += 1
        continue

More examples are these:

Software\Microsoft\Windows\CurrentVersion\Uninstall\KB951748	Aggiornamento della protezione per Windows XP (KB951748) --> THIS IS OK
Software\Microsoft\Windows\CurrentVersion\Uninstall\KB951978   	                                                         --> NOT OK, but DisplayName = Aggiornamento per Windows XP (KB951978)
Software\Microsoft\Windows\CurrentVersion\Uninstall\KB952004	Aggiornamento della protezione per Windows XP (KB952004) --> THIS IS OK
Software\Microsoft\Windows\CurrentVersion\Uninstall\7-Zip	                                                         --> NOT OK, but DisplayName = 7-Zip 4.65
Software\Microsoft\Windows\CurrentVersion\Uninstall\Adobe Flash Player ActiveX	                                         --> NOT OK, but DisplayName = Adobe Flash Player 10 ActiveX
Software\Microsoft\Windows\CurrentVersion\Uninstall\Adobe Shockwave Player	                                         --> NOT OK, but DisplayName = Adobe Shockwave Player 11.5
Software\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft .NET Framework 3.5 SP1	Microsoft .NET Framework 3.5 SP1 --> THIS IS OK


Thanks again



More information about the python-win32 mailing list