python script to find Installed programs in Uninstall folder in registry

Discussion in 'Python' started by KishoreRP, Mar 15, 2011.

  1. KishoreRP

    KishoreRP Guest

    I am working on creating a python script to find Installed programs in
    Uninstall folder in registry, the script works perfectly fine on 32
    bit machines but errors out with a wmi error on 64 bit machines. Am
    not able to get hold of a wmi module for python on 64 bit machines.Is
    there one at all? Please ignore indentation errors. I found this
    script in some forum, apologies for not giving due credit to the
    corresponding author
    r = wmi.Registry()
    result, names = r.EnumKey (hDefKey=HKEY_LOCAL_MACHINE,
    sSubKeyName=r"Software\Microsoft\Windows\CurrentVersion\Uninstall")

    separator = "*" * 80
    keyPath = r"Software\Microsoft\Windows\CurrentVersion\Uninstall"
    for subkey in names:
    try:

    path = keyPath + "\\" + subkey
    key = OpenKey(HKEY_LOCAL_MACHINE, path, 0, KEY_ALL_ACCESS)

    try:
    temp = QueryValueEx(key, 'DisplayName')
    temp1 = QueryValueEx(key, 'DisplayVersion')
    temp2 = QueryValueEx(key, 'Publisher')
    display = str(temp[0])
    display_ver=str(temp1[0])
    display_p=str(temp2[0])

    print ('Display Name: ' + display + '\nDisplay
    version: ' + display_ver + '\nVendor/Publisher: ' + display_p
    +'\nRegkey: ' + subkey + '\n')

    except:
    print ('Regkey: ' + subkey + '\n')


    except:
    fp = StringIO.StringIO()
    traceback.print_exc(file=fp)
    errorMessage = fp.getvalue()
    #error = 'Error for ' + key + '. Message follows:\n' +
    errorMessage
    #HelperFuncs.LogError(error)
     
    KishoreRP, Mar 15, 2011
    #1
    1. Advertising

  2. KishoreRP

    Tim Golden Guest

    Re: python script to find Installed programs in Uninstall folderin registry

    On 15/03/2011 03:42, KishoreRP wrote:
    > I am working on creating a python script to find Installed programs in
    > Uninstall folder in registry, the script works perfectly fine on 32
    > bit machines but errors out with a wmi error on 64 bit machines.


    You don't say what the error is (and your snippet doesn't run without
    some alterations) so would you mind showing just enough code for
    the error to occur plus a cut-and-paste of the traceback?

    > Am not able to get hold of a wmi module for python on 64 bit machines.
    > Is there one at all?


    The wmi module is pure Python, relying only on Python & the pywin32
    extensions. If you have both of those installed as 64-bit you can
    just drop the wmi.py module into the right place and go from there.


    TJG
     
    Tim Golden, Mar 15, 2011
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brad Tilley
    Replies:
    5
    Views:
    3,194
    Brad Tilley
    Dec 1, 2004
  2. Replies:
    0
    Views:
    419
  3. Replies:
    12
    Views:
    2,295
    excord80
    Dec 15, 2008
  4. Rahul
    Replies:
    0
    Views:
    587
    Rahul
    Apr 24, 2008
  5. Am Nym
    Replies:
    4
    Views:
    702
    Am Nym
    May 21, 2012
Loading...

Share This Page