![]() ![]() ![]() ![]() |
|||||
|
|||||
樓主 ahlam ![]()
![]() |
工作原理:讀取 windows 裡面的 registry 然後將已經安裝過的 HotFix 列出來。 # -*- coding: UTF-8 -*- import re from _winreg import * def subRegKey(key, pattern, patchlist): #個數 count = QueryInfoKey(key)[0] for index in range(count): #獲取標題 name = EnumKey(key, index) result = patch.match(name) if result: patchlist.append(result.group(1)) sub = OpenKey(key, name) subRegKey(sub, pattern, patchlist) CloseKey(sub) if __name__ == '__main__': patchlist = [] updates = 'SOFTWARE\\Microsoft\\Updates' patch = re.compile('(KB\d{6}).*') key = OpenKey(HKEY_LOCAL_MACHINE, updates) subRegKey(key, patch, patchlist) print 'Count: ' + str(len(patchlist)) for p in patchlist: print p CloseKey(key)
本篇文章發表於2013-03-25 11:48
|