当前位置:   article > 正文

获取本机软件安装目录_获取软件安装目录

获取软件安装目录

使用python脚本获取本机安装的所有软件的信息,并保存到本地

import os
import winreg

def get_installed_apps():
    apps = []
    with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\\Microsoft\Windows\\CurrentVersion\\Uninstall") as key:
        for i in range(0, winreg.QueryInfoKey(key)[0]):
            subkey_name = winreg.EnumKey(key, i)
            with winreg.OpenKey(key, subkey_name) as subkey:
                try:
                    app_name = winreg.QueryValueEx(subkey, "DisplayName")[0].encode('utf-8')
                    if app_name not in apps:
                        apps.append(app_name)
                except OSError:
                    pass
    return apps

app_list = get_installed_apps()
with open(os.path.join(os.getcwd(), 'app_list.txt'), "w") as f:
    for i in app_list:
        f.write("{}\n".format(i))
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/726295
推荐阅读
相关标签
  

闽ICP备14008679号