[python-win32] get installed software remote machine

Tim Golden mail at timgolden.me.uk
Tue Apr 27 11:12:08 CEST 2010


On 27/04/2010 09:36, pacopyc wrote:
> 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)

Ignoring other complications... you're querying the keys on the
remote machine "XXXX". But you're then using _winreg to query
the values on the local machine. Why not continue to use the
WMI registry methods:

   http://msdn.microsoft.com/en-us/library/aa393664%28VS.85%29.aspx

to query the remote keys?

By the way, the pythonic thing to do is to iterate over lists
directly. You don't need to do the "while i < len (list)" dance.
Just:

for name in names:
   try:
     # do stuff with OpenKey ("..." + name)
   except <some Exception class>:
     # handle and move on

Also, don't put a bare "except:" unless you're absolutely sure
you'll need it. In the code below, that except: would silently
ignore even a NameError or a Ctrl-C.

TJG


More information about the python-win32 mailing list