SoFunction
Updated on 2024-11-17

Python implementation to find installation information for all programs

As the question is answered, the answer is: look through the registry.

There are two subjugates in the windows system that store the installation information of all the programs:

1,HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Compatibility Assistant\Store

Below is the sample python code to find the installation path of 360 browser:

import win32con, win32api

def find_360se_path(): 
 upper_keyword = '' 
 path = None 
 sub_key = r'Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Compatibility Assistant\Store' 
 key = (win32con.HKEY_CURRENT_USER, sub_key, 0, win32con.KEY_READ) 
 info = (key) 
 for i in range(0, info[1]):  
  value = (key, i)  
  if value[0].upper().endswith(upper_keyword):
   path = value[0]   
   break 
 (key) 
 return path

2,HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths

Below is the sample python code to find the installation path of 360 browser:

import win32con, win32apidef 

find_360se_path(): 
 upper_value_keyword = '' 
 upper_item_name_keyword = '' 
 path = None 
 sub_key1 = r'SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths' 
 key1 = (win32con.HKEY_LOCAL_MACHINE, sub_key1, 0, win32con.KEY_READ) 
 info1 = (key1) 
 for i in range(0, info1[0]):  
  key_name = (key1, i)  
  if key_name.upper() == upper_item_name_keyword:
   sub_key2 = sub_key1 + '\\' + key_name
   key2 = (win32con.HKEY_LOCAL_MACHINE, sub_key2, 0, win32con.KEY_READ)   
   info2 = (key2)   
   for j in range(0, info2[1]):    
    key_value = (key2, j)[1]
    if key_value.upper().endswith(upper_value_keyword): 
     path = key_value     
     break   
   (key2)   
  break 
 (key1) 
 return path