2024-05-02 00:13:10 +02:00
@ echo off
2024-06-12 19:45:10 +02:00
: : This script allowed to remove the whole "Get Windows 10" annoyances on Windows7
2024-05-02 00:13:10 +02:00
: : Writed by CynerOne, updated and commented by Albirew
: : CynerOne original located here: http://lecrabeinfo.net/desinstaller-lapplication-obtenir-windows-10-supprimer-icone-windows-10.html#comment-2374542969
: : also added rev.18 of Matt's privilege escalation script: http://stackoverflow.com/posts/12264592/revisions
: : V2 added Inny suggestion: http://www.nextinpact.com/news/97735-microsoft-se-fait-plus-insistant-sur-migration-vers-windows-10.htm#/comment/5555097
: : V3 added Timo's list: http://lehollandaisvolant.net/?d=2016/01/16/13/29/06-windows-78-bloquer-les-mises-a-niveau-vers-windows-10
: : V4 escaped chevrons inside echo (my bad)
: : V5 reordered updates removal by kb number for readability and added some of isleaked updates: https://fix10.isleaked.com/oldwindows.html
: : V6 modified error check to make it not stop when non fatal error occur and added script to automatically hide nasty updates on Windows Update ( https://gist.github.com/neckcen/f099eda0b1cde283cdc9 )
: : V7 added WGA update and fixed lack of escaping characters
: : V8 added KB3173040
2024-06-12 19:45:10 +02:00
: : V9 added script description
2024-05-02 00:13:10 +02:00
: : before anything, let's specify what "yes" is interpreted in your language (for takeown)
for /F " tokens=3 delims= " %% G in ( 'reg query "hklm\system\controlset001\control\nls\language" /v Installlanguage' ) do (
if [%% G] equ [040C] ( set yes = o ) else ( set yes = y )
)
: : First, we escalate privileges of the terminal
: checkPrivileges
NET FILE 1 > NUL 2 > NUL
if '%errorlevel% ' == '0' ( goto gotPrivileges ) else ( goto getPrivileges )
: getPrivileges
if '%1 '== 'ELEV' ( echo ELEV & shift /1 & goto gotPrivileges )
echo .
echo Invoking UAC for Privilege Escalation
setlocal DisableDelayedExpansion
set " batchPath= %~0 "
setlocal EnableDelayedExpansion
echo Set UAC = CreateObject^( " Shell.Application " ^) > " %temp% \OEgetPrivileges.vbs "
echo args = " ELEV " >> " %temp% \OEgetPrivileges.vbs "
echo For Each strArg in WScript.Arguments >> " %temp% \OEgetPrivileges.vbs "
echo args = args ^& strArg ^& " " >> " %temp% \OEgetPrivileges.vbs "
echo Next >> " %temp% \OEgetPrivileges.vbs "
echo UAC.ShellExecute " !batchPath! " , args, " " , " runas " , 1 >> " %temp% \OEgetPrivileges.vbs "
" %SystemRoot% \System32\WScript.exe " " %temp% \OEgetPrivileges.vbs " %*
exit /B
: gotPrivileges
if '%1 '== 'ELEV' shift /1
setlocal & pushd .
cd /d %~dp0
: : privilege escalation OK
: : this is the hide update script here
echo If Wscript.Arguments.Count ^< 1 Then > " %temp% \banUpdate.vbs "
echo WScript.Echo " Syntax: HideWindowsUpdates.vbs [KB1] [KB2] ... " ^& vbCRLF ^& _ >> " %temp% \banUpdate.vbs "
echo " - Example1: HideWindowsUpdates.vbs 3035583 " ^& vbCRLF ^& _ >> " %temp% \banUpdate.vbs "
echo " - Example2: HideWindowsUpdates.vbs 3035583 3012973 " >> " %temp% \banUpdate.vbs "
echo WScript.Quit 1 >> " %temp% \banUpdate.vbs "
echo End If >> " %temp% \banUpdate.vbs "
echo . >> " %temp% \banUpdate.vbs "
echo Dim objArgs >> " %temp% \banUpdate.vbs "
echo Set objArgs = Wscript.Arguments >> " %temp% \banUpdate.vbs "
echo Dim updateSession, updateSearcher >> " %temp% \banUpdate.vbs "
echo Set updateSession = CreateObject(" Microsoft.Update.Session " ) >> " %temp% \banUpdate.vbs "
echo Set updateSearcher = updateSession.CreateUpdateSearcher() >> " %temp% \banUpdate.vbs "
echo . >> " %temp% \banUpdate.vbs "
echo WScript.Echo " Searching for pending updates... " >> " %temp% \banUpdate.vbs "
echo Dim searchResult >> " %temp% \banUpdate.vbs "
echo Set searchResult = updateSearcher.Search(" IsInstalled=0 " ) >> " %temp% \banUpdate.vbs "
echo . >> " %temp% \banUpdate.vbs "
echo Dim update, kbArticleId, index, index2 >> " %temp% \banUpdate.vbs "
echo WScript.Echo CStr(searchResult.Updates.Count) ^& " found. " >> " %temp% \banUpdate.vbs "
echo For index = 0 To searchResult.Updates.Count - 1 >> " %temp% \banUpdate.vbs "
echo Set update = searchResult.Updates.Item(index) >> " %temp% \banUpdate.vbs "
echo For index2 = 0 To update.KBArticleIDs.Count - 1 >> " %temp% \banUpdate.vbs "
echo kbArticleId = update.KBArticleIDs(index2) >> " %temp% \banUpdate.vbs "
echo . >> " %temp% \banUpdate.vbs "
echo For Each hotfixId in objArgs >> " %temp% \banUpdate.vbs "
echo If kbArticleId = hotfixId Then >> " %temp% \banUpdate.vbs "
echo If update.IsHidden = False Then >> " %temp% \banUpdate.vbs "
echo WScript.Echo " Hiding update: " ^& update.Title >> " %temp% \banUpdate.vbs "
echo update.IsHidden = True >> " %temp% \banUpdate.vbs "
echo Else >> " %temp% \banUpdate.vbs "
echo WScript.Echo " Already hidden: " ^& update.Title >> " %temp% \banUpdate.vbs "
echo End If >> " %temp% \banUpdate.vbs "
echo End If >> " %temp% \banUpdate.vbs "
echo Next >> " %temp% \banUpdate.vbs "
echo Next >> " %temp% \banUpdate.vbs "
echo Next >> " %temp% \banUpdate.vbs "
: : EOF
color 0a
echo GWX / GWX Schedule / Windows spy updates search ^& destroy
echo ----------------------------------------------
timeout 3
color 0e
set TO_HIDE =
: : now time to remove nasty update
echo Uninstalling KB971033 (WGA)
wusa /uninstall /kb:971033 /quiet /norestart
set TO_HIDE = %TO_HIDE% 971033
echo Uninstalling KB2952664 (Get Windows 10 assistant)
wusa /uninstall /kb:2952664 /quiet /norestart
set TO_HIDE = %TO_HIDE% 2952664
echo Uninstalling KB2976978 (telemetry for Win8/8.1)
wusa /uninstall /kb:2976978 /quiet /norestart
set TO_HIDE = %TO_HIDE% 2976978
echo Uninstalling KB2977759 (telemetry for Win7)
wusa /uninstall /kb:2977759 /quiet /norestart
set TO_HIDE = %TO_HIDE% 2977759
echo Uninstalling KB2990214 (Get Windows 10 for Win7)
wusa /uninstall /kb:2990214 /quiet /norestart
set TO_HIDE = %TO_HIDE% 2990214
echo Uninstalling KB3021917 (installs telemetry for CEIP)
wusa /uninstall /kb:3021917 /quiet /norestart
set TO_HIDE = %TO_HIDE% 3021917
echo Uninstalling KB3022345 (telemetry)
wusa /uninstall /kb:3022345 /quiet /norestart
set TO_HIDE = %TO_HIDE% 3022345
echo Uninstalling KB3035583 (GWX Notification)
wusa /uninstall /kb:3035583 /quiet /norestart
set TO_HIDE = %TO_HIDE% 3035583
echo Uninstalling KB3044374 (Get Windows 10 for Win8.1)
wusa /uninstall /kb:3044374 /quiet /norestart
set TO_HIDE = %TO_HIDE% 3044374
echo Uninstalling KB3068708 (telemetry)
wusa /uninstall /kb:3068708 /quiet /norestart
set TO_HIDE = %TO_HIDE% 3068708
echo Uninstalling KB3075249 (telemetry for Win7/8.1)
wusa /uninstall /kb:3075249 /quiet /norestart
set TO_HIDE = %TO_HIDE% 3075249
echo Uninstalling KB3080149 (telemetry for Win7/8.1)
wusa /uninstall /kb:3080149 /quiet /norestart
set TO_HIDE = %TO_HIDE% 3080149
echo Uninstalling KB3112336 (New Win8.1-^> 10 upgrade scenario)
wusa /uninstall /kb:3112336 /quiet /norestart
set TO_HIDE = %TO_HIDE% 3112336
echo Uninstalling KB3112343 (New Win7-^> 10 upgrade scenario)
wusa /uninstall /kb:3112343 /quiet /norestart
set TO_HIDE = %TO_HIDE% 3112343
echo Uninstalling KB3123862 (Updated capabilities to upgrade Windows 8.1 and Windows 7)
wusa /uninstall /kb:3123862 /quiet /norestart
set TO_HIDE = %TO_HIDE% 3123862
echo Uninstalling KB3173040 (end of free upgrade offer notification (another spam) for Windows 8.1 and Windows 7)
wusa /uninstall /kb:3173040 /quiet /norestart
set TO_HIDE = %TO_HIDE% 3173040
echo now, let's hide these nasty updates
echo (this WILL take a while)
" %SystemRoot% \System32\WScript.exe " " %temp% \banUpdate.vbs " %TO_HIDE%
timeout 30
: : then taking ownership of remnant folders
echo Take control for all folders GWX
timeout 3
: : let's check if GWX was already removed
set error = 0
if not exist %windir% \System32\GWX set error = %error% +1
if not exist %windir% \SysWOW64\GWX set error = %error% +1
if %error% == 2 set error1 = 1
takeown /F %windir% \System32\GWX /A /R /D %yes%
takeown /F %windir% \SysWOW64\GWX /A /R /D %yes%
takeown /F %windir% \System32\Tasks\Microsoft\Windows\Setup /A /R /D %yes%
echo Change rights for all folders GWX
timeout 3
icacls %windir% \System32\GWX /grant " %username% " :(F) /T /C
icacls %windir% \SysWOW64\GWX /grant " %username% " :(F) /T /C
icacls %windir% \System32\Tasks\Microsoft\Windows\Setup /grant " %username% " :(F) /T /C
: : ok, now time to kill executable and remove this shit out of our computer
echo Delete all GWX files and folders
timeout 3
echo Before kill GWX.exe if necessary
taskkill /f /t /im GWX.exe
timeout 3
del /F /S /Q /A %windir% \System32\GWX\*
rd /S /Q %windir% \System32\GWX
: : some error handling (see eof)
if exist %windir% \System32\GWX set error1 = 2
del /F /S /Q /A %windir% \SysWOW64\GWX\*
rd /S /Q %windir% \SysWOW64\GWX
if exist %windir% \SysWOW64\GWX set error1 = 2
: : removing related sheduled tasks
del /F /S /Q /A %windir% \System32\Tasks\Microsoft\Windows\Setup\*
rd /S /Q %windir% \System32\Tasks\Microsoft\Windows\Setup\gwx
rd /S /Q %windir% \System32\Tasks\Microsoft\Windows\Setup\GWXTriggers
: : setting policy to disable GWX
reg add " HKLM\SOFTWARE\Policies\Microsoft\Windows\Gwx "
reg add " HKLM\SOFTWARE\Policies\Microsoft\Windows\Gwx " /v DisableGwx /t REG_DWORD /d 1
: : prevent further upgrade
reg add " HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate " /v DisableOSUpgrade /t REG_DWORD /d 1 /f
reg add " HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\OSUpgrade "
reg add " HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\OSUpgrade " /v AllowOSUpgrade /t REG_DWORD /d 0
reg add " HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\OSUpgrade " /v ReservationsAllowed /t REG_DWORD /d 0
if error1== 1 goto error1
if error1== 2 goto error2
color 0a
echo Cleaned. Have a nice day.
pause
exit
: error1
color 0c
echo GWX does not seems to be installed. Tried to clean everything anyway.
pause
exit
: error2
color 0c
echo Cannot remove GWX folder, are you really running this as admin? Tried to clean what I can anyway.
pause
exit