python获取软件安装列表2222

softer_installed_list =====================

使用python编写的,获取本机软件安装列表,输出为html表格.

* win7 32位环境下运行

* 使用的是"**SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall**"

下的软件安装列表

* 生成文件保存为index.html

* 示例地址:http://sharedoc.sinaapp.com/install-list/

* gitbhub地址为:https://github.com/urmyfaith/softer_installed_list/

* 运行不需要参数,双击softer_installed_list.py即可.(需要安装python2.x)

主要代码:

```python key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall", 0, _winreg.KEY_ALL_ACCESS) for i in xrange(0, _winreg.QueryInfoKey(key)[0]-1): try: key_name_under_uninstall=_winreg.EnumKey(key, i) #print key_name_under_uninstall each_key_path="SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"+'\\'+ key_name_under_uninstall #print each_key_path each_key= _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,each_key_path,0, _winreg.KEY_ALL_ACCESS) try: softer_ware_name,typeresult= _winreg.QueryValueEx(each_key,"DisplayName") softer_ware_name=softer_ware_name.encode('utf-8')

try: InstallLocation_name,typeresult= _winreg.QueryValueEx(each_key,"InstallLocation") InstallLocation_name = InstallLocation_name.encode('utf-8') if InstallLocation_name=="": InstallLocation_name="NULL" except WindowsError: InstallLocation_name="NULL" html_table = html_table + html_tr_left_str + str(i+1) + '''''' + softer_ware_name + '''''' + InstallLocation_name + html_tr_right_str except WindowsError: pass except WindowsError: pass

```

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值