得到系统删除程序里的FIREFOX

from _winreg import *
import re
def subRegKey(key, patchlist):
    count = QueryInfoKey(key)[0]
    for index in range(count):
        name = EnumKey(key, index)
        result = patch.match(name)
        if result:
            patchlist.append(result.group(0))

if __name__ == '__main__':
    patchlist = []
    updates = 'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\'
    patch = re.compile(r'Mozilla Firefox(.*)')
    key = OpenKey(HKEY_LOCAL_MACHINE, updates)
    subRegKey(key, patchlist)
    print 'Count: ' + str(len(patchlist))
    for p in patchlist:
        print p
    update = updates + p
    print update
    newkey = OpenKey(HKEY_LOCAL_MACHINE, update)
    try:
        i = 0
        while 1:
            name, value, type = EnumValue(newkey, i)
            if name == "DisplayVersion":
                print value
                break
            i+=1
    except WindowsError:
        pass
    CloseKey(key)

posted on 2011-08-08 19:46  Cheney Shen  阅读(130)  评论(0编辑  收藏  举报

导航