Use Python to get a list of machine-installed programs by reading the registry, including, software name, version number, installation date, etc.
#-*-Coding:utf8-*-
Import _winreg
Import OS
Import Commmethod
1.
"Get the list of programs under Software\microsoft\windows\currentversion\app paths"
def getapppathsregeditinfo (list):
KeyPath = r "Software\microsoft\windows\currentversion\app Paths"
Key = _winreg. Openkey (_winreg. HKEY_LOCAL_MACHINE, KeyPath, 0, _winreg. key_all_access)
Listkeys = _winreg. Queryinfokey (Key)
For I in Xrange (0,listkeys[0]-1):
Key_name_list =_winreg. EnumKey (key, I)
Each_key_path = keypath + ' \ \ ' + key_name_list
Try
Each_key = _winreg. Openkey (_winreg. HKEY_LOCAL_MACHINE, Each_key_path, 0, _winreg. Key_read)
FPATH,REG_SZ = _winreg. QueryValueEx (Each_key, "")
Finfo = Commmethod.getfileinfo (Fpath)
List.append (Finfo)
Except
Continue
2.
"Get a list of programs under Software\microsoft\windows\currentversion\uninstall"
def getuninstallregeditinfo (list):
KeyPath = r "Software\microsoft\windows\currentversion\uninstall"
Key = _winreg. Openkey (_winreg. HKEY_LOCAL_MACHINE, KeyPath, 0, _winreg. key_all_access)
For I in Xrange (0,_winreg. Queryinfokey (key) [0]-1):
Key_name_list =_winreg. EnumKey (key, I)
Each_key_path = keypath+ ' \ \ ' +key_name_list
Each_key = _winreg. Openkey (_winreg. HKEY_LOCAL_MACHINE, Each_key_path, 0, _winreg. key_all_access)
Try
DisplayName, REG_SZ = _winreg. QueryValueEx (Each_key, "DisplayName")
#DisplayName = Displayname.encode (' Utf-8 ')
DisplayVersion, REG_SZ = _winreg. QueryValueEx (Each_key, "DisplayVersion")
InstallDate, REG_SZ = _winreg. QueryValueEx (Each_key, "InstallDate")
if (Len (DisplayName) >0 and Len (displayversion) >0 and Len (installdate) >0):
Finfo = Commmethod.softwareinfo (displayname,installdate,displayversion)
List.append (Finfo)
Except Windowserror:
Pass
Python program list