Skip to content

Instantly share code, notes, and snippets.

@Citillara
Last active January 17, 2024 12:26
Show Gist options
  • Star 26 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save Citillara/3ad19ce3314a0964758f to your computer and use it in GitHub Desktop.
Save Citillara/3ad19ce3314a0964758f to your computer and use it in GitHub Desktop.
Windows 7 updates to remove to prevent telemetry collection. Disables automatic upgrade to Windows 10
:: Removes most telemetry/data collection/potentially unwanted behavior from Windows 7
:: Disables the automatic download of Windows 10
:: Note : be careful to keep KB in descending order
:: Comment that line to restore prompts for uninstall/reboot
:: Thanks to https://gist.github.com/geoffroyjabouley
set WUSA_OPTIONS=/quiet /norestart
:: Removes Windows 7-8.1 telemetry (part 1)
wusa %WUSA_OPTIONS% /uninstall /kb:3080149
wusa %WUSA_OPTIONS% /uninstall /kb:3075249
wusa %WUSA_OPTIONS% /uninstall /kb:3068708
:: Removes the "Get Windows 10" (GWX)
wusa %WUSA_OPTIONS% /uninstall /kb:3035583
:: Removes Windows 7-8.1 telemetry (part 2)
wusa %WUSA_OPTIONS% /uninstall /kb:3022345
wusa %WUSA_OPTIONS% /uninstall /kb:3021917
wusa %WUSA_OPTIONS% /uninstall /kb:2952664
:: Removes the "pinning" for updating Windows 7 to a later version
wusa %WUSA_OPTIONS% /uninstall /kb:2990214
:: Prevents Windows from automatically download files to prepare move to Windows 10
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v DisableOSUpgrade /t REG_DWORD /d 1 /f
:: Disable notifications for upgrade to Windows 10
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\OSUpgrade" /v ReservationsAllowed /t REG_DWORD /d 0 /f
@ffes
Copy link

ffes commented Oct 15, 2015

I added

wusa %WUSA_OPTIONS% /uninstall /kb:3080351

and

reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\OSUpgrade" /v AllowOSUpgrade  /t REG_DWORD /d 0 /f

Now the new (since Patch Tuesday of October) "Upgrade to Win10" screen in Windows Update is gone, but most of the updates I just uninstalled are back to be installed, and marked as important. Don't know how to fix that with a batch file. Hiding them with the UI seems to work so far.

@Lomanic
Copy link

Lomanic commented Nov 5, 2015

Don't know how to fix that with a batch file. Hiding them with the UI seems to work so far.

@ffes You can use the following vbscript found in this superuser answer, by adding at the end of the .bat file cscript HideWindowsUpdates.vbs 3080149 3075249 3068708 3035583 3022345 3021917 2952664 2990214

'// Inspired by Colin Bowern: http://serverfault.com/a/341318
If Wscript.Arguments.Count < 1 Then
    WScript.Echo "Syntax: HideWindowsUpdates.vbs [KB1] [KB2] ..." & vbCRLF & _
        " - Example1: HideWindowsUpdates.vbs 3035583" & vbCRLF & _
        " - Example2: HideWindowsUpdates.vbs 3035583 3012973"
    WScript.Quit 1
End If

Dim objArgs
Set objArgs = Wscript.Arguments
Dim updateSession, updateSearcher
Set updateSession = CreateObject("Microsoft.Update.Session")
Set updateSearcher = updateSession.CreateUpdateSearcher()

Wscript.Stdout.Write "Searching for pending updates..."
Dim searchResult
Set searchResult = updateSearcher.Search("IsInstalled=0")

Dim update, kbArticleId, index, index2
WScript.Echo CStr(searchResult.Updates.Count) & " found."
For index = 0 To searchResult.Updates.Count - 1
    Set update = searchResult.Updates.Item(index)
    For index2 = 0 To update.KBArticleIDs.Count - 1
        kbArticleId = update.KBArticleIDs(index2)

        For Each hotfixId in objArgs
            If kbArticleId = hotfixId Then
                If update.IsHidden = False Then
                    WScript.Echo "Hiding update: " & update.Title
                    update.IsHidden = True
                Else
                    WScript.Echo "Already hidden: " & update.Title
                End If
            End If
        Next

    Next
Next
'// EOF

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment