Script for removing Windows 7 updates that should “ease the upgrade to Windows 10”

For those who are running Windows 7 and (just like me) don’t want to upgrade to Windows 10, here’s a script to remove all Microsoft updates contributing to the upgrade. It fetches the documentation for all installed updates (not security related and starting from 2015) and looks for certain keywords inside that documentation. Currently it removes everything mentioning “Windows 10”, “ease the upgrade experience”, “upgrading” or “telemetry”. You can change this to your own words inside the script.
Note, this should also remove KB3035583 that gives the Windows 10 upgrade icon in the taskbar. That tray icon should be gone after running the script.
It also tries to remove all telemetry features which collects all sorts of user activity and sends it to Microsoft. It is enabled in Windows 10 by default and Microsoft hasn’t provided an option to completely disable it for Home and Pro users. Some telemetry updates are installed in Windows 7 as well, for example KB3068708.

The script is written in Python2. If you don’t have it, install the latest version here: https://www.python.org/downloads/. I have only tried it on Windows 7 x86, but it probably works on 8(.1) and 64-bit as well.

import subprocess
import urllib2
import sys
import time

keywords = [" ease the upgrade experience ", " Windows 10 ", " upgrading ", " telemetry "] #keywords to look for inside the documentation
startKB = 0 #start from a certain KB number

removing = []
kbs = []

def run_command(command):
    p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
    return iter(p.stdout.readline, b'')

print "Getting installed updates list..."
command = 'wmic qfe list'.split()
for line in run_command(command):
     for str in line.split(" "):
          if str.startswith("KB") and not "Security Update" in line and "2015" in line:
               kb = str[2:]
               if int(kb) > int(startKB):
                    kbs.append(kb)

print "Found %s updates" % (len(kbs))
print "Fetching KB documentations (this might take a while)..."
i=1
for kb in kbs:
    time.sleep(1)
    url = "https://support.microsoft.com/api/content/kb/"+kb
    req = urllib2.Request(url)
    try:
        f = urllib2.urlopen(req)
        html = f.read()
        if any(x in html for x in keywords):
            removing.append(kb)
            print "[%i] KB%s: Bad, see %s" % (i, kb, url)
        else:
            print "[%i] KB%s: Good" % (i, kb)
    except urllib2.URLError as e:
        print "[%i] KB%s: %s" % (i, kb, e.reason)
    i=i+1

print
if len(removing) == 0:
    print "Nothing found!"
    sys.exit(1)

print "Ready to remove following updates:"
print removing
print "They will be uninstalled one by one. You can choose individually whether you want it removed or not."
proceed =  raw_input("Continue? [Y,n] ")
print
if (proceed == "") or (proceed == "y") or (proceed == "Y") or (proceed == "yes"):
    for kb in removing:
        print "Removing KB%s..." % kb
        subprocess.call(["wusa.exe","/uninstall","/kb:"+kb,"/norestart"], shell=True)