• Python获取软件安装列表


    python获取软件安装列表

    #!/usr/bin/python
    
    import os
    import socket
    import winreg
    
    # 检测主机名,并将主机名作文检测结果的文件名
    file = open(r'd:123Soft.txt')
    
    # 定义检测位置
    sub_key = [r'SOFTWAREMicrosoftWindowsCurrentVersionUninstall',
               r'SOFTWAREWow6432NodeMicrosoftWindowsCurrentVersionUninstall']
    
    software_name = []
    adobe = 'adobe'
    for i in sub_key:
        key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, i, 0, winreg.KEY_ALL_ACCESS)
        for j in range(0, winreg.QueryInfoKey(key)[0] - 1):
            try:
                key_name = winreg.EnumKey(key, j)
                key_path = i + '\' + key_name
                each_key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, key_path, 0, winreg.KEY_ALL_ACCESS)
                DisplayName, REG_SZ = winreg.QueryValueEx(each_key, 'DisplayName')
                DisplayVersion, REG_SZ1 = winreg.QueryValueEx(each_key, 'DisplayVersion')
                Publisher, REG_SZ2 = winreg.QueryValueEx(each_key, 'Publisher')
                InstallDate, REG_SZ3 = winreg.QueryValueEx(each_key, 'InstallDate')
                DisplayName = DisplayName.encode('utf-8')
                software_name.append(DisplayName)
            except WindowsError:
                pass
    
    software_name = list(set(software_name))
    software_name = sorted(software_name)
    
    for result in software_name:
        print(result.decode("utf-8"))
        # print(result.decode("gbk"))
        # file.write(str(result) + '
    ')
    file.close()
  • 相关阅读:
    分享jQuery的常用技巧12招
    浅析淘宝数据魔方技术架构
    JavaScript的跨域共享的方法
    PHP实现QQ达人信息抓取
    Dreamweaver CS5.5试用小感和破解方法附下载地址
    ExtJS 4应用架构设计
    webkit webApp 开发技术要点总结
    用delphi编写ISAPI过滤器
    1020卡免费共享测试!
    一些有用的網站
  • 原文地址:https://www.cnblogs.com/LoganChen/p/14074380.html
Copyright © 2020-2023  润新知