Created
August 15, 2024 21:25
-
-
Save fovtran/7b4623ee8b44776c4161488239d49340 to your computer and use it in GitHub Desktop.
Win32 get a list of current installed hotfixes download URLs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from xml.dom import minidom | |
from urllib import request,robotparser | |
import lxml.html | |
xml = os.popen('wmic qfe list /FORMAT:rawxml') | |
LANG = 'ES-es' # language of hotfix files | |
_hotfix = {} | |
counter = 0 | |
wmic = minidom.parseString(xml.read()) | |
node1 = wmic.firstChild | |
instances = node1.childNodes[2].childNodes[0].childNodes | |
for instance in instances: | |
qfe = {} | |
if instance.nodeName == 'INSTANCE': | |
if instance.getAttribute('CLASSNAME') == 'Win32_QuickFixEngineering': | |
counter +=1 | |
for property in instance.childNodes: | |
for cim in property.childNodes: | |
if cim.nodeType == cim.ELEMENT_NODE: | |
p = property.getAttribute('NAME') | |
for val in cim.childNodes: | |
qfe[p] = val.nodeValue | |
else: | |
print(instance.attributes) | |
try: | |
_hotfix[qfe['HotFixID']] = qfe | |
except: | |
print("Instance Error") | |
for hotfix in _hotfix.keys(): | |
kb = hotfix | |
for pq in _hotfix[hotfix]: | |
if 'Caption' in pq: | |
_url = _hotfix[hotfix]['Caption'] | |
print(kb, _url) | |
testurl = 'https://support.microsoft.com/es-es/hotfix/kbhotfix?kbnum=' + kb + '&kbln=' + LANG | |
f = request.urlopen(testurl) | |
dom = lxml.html.fromstring(f.read()) | |
for link in dom.xpath('//a/@href'): | |
print(link) | |
print(target) | |
print("Total: ", len(_hotfix)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment