pf100

Sledgehammer-v2.7.3rc1.cmd

Oct 29th, 2020 (edited)
793
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.21 KB | None | 0 0
  1. @echo off
  2. mode con cols=89 lines=34
  3. Title Sledgehammer 2.7.3
  4. Color 1F & goto start
  5. Original script by pf100 @ MDL with special thanks to rpo and abbodi1406 @ MDL for code improvements.
  6. Thanks to RetiredGeek at askwoody.com forum for original ideas on how to get MS-DEFCON rating.
  7. Project page and source code:
  8. https://forums.mydigitallife.net/threads/sledgehammer-windows-10-update-control.72203/
  9. ******************************************************************
  10. You may freely modify this script as you wish, I only request that you leave the credits and the
  11. link to the original script.
  12. ******************************************************************
  13. Don't move this script to another folder without running it again or the tasks won't work!
  14. This script provides manual updating for Windows 10 including Home versions.
  15. Update Windows 10 on your schedule, not Microsoft's!
  16. I originally wrote this script for personal use because of the lack of update options with the
  17. original RTM release of Windows 10 Pro. I wanted to update Windows 10 when I had the free time
  18. to manually update, just like I did with previous versions of Windows that allowed me to
  19. set updates to manual, not when Microsoft forced it on me while I was busy using my computer.
  20. *******************************************************************
  21. WUMT is available here: https://forums.mydigitallife.net/threads/64939-Windows-Update-MiniTool
  22. Windows Update Blocker is available here: http://sordum.org/files/windows-update-blocker/old/Wub_v1.0.zip
  23. Only use Windows Update Blocker v1.0 with this script, NOT v1.1!
  24. NSudo is available here: https://github.com/M2Team/NSudo/releases/tag/6.1
  25. *******************************************************************
  26. How it works: The script first checks if the OS is Windows 8.1 or older and if so
  27. it notifies the user, then exits. Windows 10 only!
  28. This script creates a smart Windows Defender Update task "WDU" that updates Windows
  29. Defender every 6 hours if it's running and enabled, and doesn't update it if it's not
  30. running and disabled, saving resources; auto-elevates, uninstalls and removes the
  31. Windows 10 Update Assistant, disables everything in the %programfiles%\rempl folder, resets and
  32. removes permissions from and disables these Update Hijackers:
  33. EOSNotify.exe
  34. WaaSMedic.exe
  35. WaasMedicSvc.dll
  36. WaaSMedicPS.dll
  37. WaaSAssessment.dll
  38. UsoClient.exe
  39. SIHClient.exe
  40. MusNotificationUx.exe
  41. MusNotification.exe
  42. osrss.dll
  43. %ProgramFiles%\rempl
  44. %systemroot%\UpdateAssistant
  45. %systemroot%\UpdateAssistantV2
  46. %systemdrive%\Windows10Upgrade
  47. disables all WindowsUpdate tasks
  48. makes sure the task "wub_task" is installed that runs wub at boot (to stop updates from turning
  49. updates back on), runs wub.exe and enables and starts the windows update service (wuauserv) if
  50. disabled, installs "WDU" Windows Defender Update task that runs every 2 hours (but doesn't update
  51. Defender if Defender is disabled), then runs the correct version of the Windows Update MiniTool in
  52. "auto search for updates" mode for your OS version's architecture (x86 or x64), then disables and
  53. stops wuauserv giving you full control. No more forced automatic updates or surprise reboots.
  54. This was written for Windows 10 Pro and Home, but works with all versions of Windows 10. Don't
  55. change any settings in lower left of WUMT while running the script.
  56. *******************************************************************
  57. I also included an uninstaller.cmd that deletes the "WDU" and "wub_task" tasks, deletes the WDU.cmd
  58. file used by WDU task, restores the rempl folder, resets Update Hijacker permissions to how they
  59. were originally, renables "WindowsUpdate" tasks, and turns off wub (if enabled) which turns the windows update service on automatic
  60. again, undoing everything done by the script. If you uninstall after having used the installer the
  61. script files are removed also.
  62. *******************************************************************
  63. Configurator leaves the Update Hijackers disabled, but gives you the option of turning on the windows
  64. update service temporarily to use the Store or any other operation that requires the windows update
  65. service, such as some DISM operations, installing dotNet 3.5, App Updates, etc.
  66. *******************************************************************
  67. :start
  68. ::::::::::::::::::::::::::::
  69. cd /d "%~dp0"
  70. :::::::::::::::::::::::::::::::::::::::::
  71. :: Automatically check & get admin rights
  72. :::::::::::::::::::::::::::::::::::::::::
  73. :: ECHO.
  74. :: ECHO =============================
  75. :: ECHO Running Admin shell
  76. :: ECHO =============================
  77. :: Check Privileges
  78. :: Get Privileges
  79. :: and
  80. :: Invoke UAC for Privilege Escalation
  81. :: Notify if error escalating
  82. :: and prevent looping if escalation fails
  83. ::::::::::::::::::::::::::::
  84. set "params=Problem_with_elevating_UAC_for_Administrator_Privileges"&if exist "%temp%\getadmin.vbs" del "%temp%\getadmin.vbs"
  85. fsutil dirty query %systemdrive% >nul 2>&1 && goto :GotPrivileges
  86. :: The following test is to avoid infinite looping if elevating UAC for Administrator Privileges failed
  87. If "%1"=="%params%" (echo Elevating UAC for Administrator Privileges failed&echo Right click on the script and select 'Run as administrator'&echo Press any key to exit...&pause>nul 2>&1&exit)
  88. cmd /u /c echo Set UAC = CreateObject^("Shell.Application"^) : UAC.ShellExecute "%~0", "%params%", "", "runas", 1 > "%temp%\getadmin.vbs"&cscript //nologo "%temp%\getadmin.vbs" && exit /b || (echo Elevating UAC for Administrator Privileges failed&echo Right click on the script and select 'Run as administrator'&echo Press any key to exit...&pause>nul 2>&1&exit)
  89. :GotPrivileges
  90. ::::::::::::::::::::::::::::
  91. ::Uninstall and remove Windows 10 Update assistant.
  92. ::Disable Windows Update Service until script menu screen.
  93. ::Reset (in case of wrong Permissions), remove Permissions from and
  94. ::disable "Update Hijackers"
  95. ::Install wub_task (prevents Windows Update service from starting after installing updates and rebooting).
  96. ::Install "WDU" task that only updates Defender if it's enabled. Otherwise it doesn't do anything.
  97. ::Enable and start the Windows Update Service (wuauserv).
  98. ::Run the correct version of WUMT for your architecture.
  99. ::Start WUMT in "auto-check for updates" mode.
  100. ::After updates are completed and WUMT is closed and/or the "reboot"
  101. ::button in WUMT is pressed, silently run wub.exe and disable and stop wuauserv
  102. ::::::::::::::::::::::::::::
  103. ::Test for Windows versions below Windows 10 and if so inform user, then exit...
  104. ::Get Windows OS build number
  105. for /f "tokens=2 delims==" %%a in ('wmic path Win32_OperatingSystem get BuildNumber /value') do (
  106. set /a WinBuild=%%a
  107. )
  108. if %winbuild% LEQ 9600 (
  109. echo.&echo This is not Windows 10. Press a key to exit...
  110. pause > nul
  111. exit
  112. )
  113. ::::::::::::::::::::::::::::
  114. ::Determine if running 32 or 64 bit Windows OS and set variables accordingly.
  115. wmic cpu get AddressWidth /value|find "32">nul&&set PROCESSOR_ARCHITECTURE=X86||set PROCESSOR_ARCHITECTURE=AMD64
  116. if %PROCESSOR_ARCHITECTURE%==AMD64 (
  117. set "nsudovar=.\bin\NSudoCx64.exe"
  118. set "wumt=.\bin\wumt_x64.exe"
  119. ) else (
  120. set "nsudovar=.\bin\NSudoc.exe"
  121. set "wumt=.\bin\wumt_x86.exe"
  122. )
  123. ::::::::::::::::::::::::::::
  124. set UpdateSettingsHide=reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer /v SettingsPageVisibility /d hide:windowsupdate /f ^>nul 2^>^&1
  125. set UpdateSettingsShow=reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer /v SettingsPageVisibility /f ^>nul 2^>^&1
  126. ::::::::::::::::::::::::::::
  127. ::Remove and/or lock Update Assistant
  128. if exist "%systemdrive%\Windows10Upgrade\Windows10UpgraderApp.exe" ( echo Windows 10 Update Assistant detected. Preparing to uninstall.
  129. echo The "Windows 10 Update Assistant has stopped working" dialog box may pop up.
  130. echo If so, just close it.
  131. echo.& echo Press a key to acknowledge this and please wait for the uninstall to finish.
  132. echo Script will continue after uninstall and removal is completed...
  133. pause > nul
  134. echo Uninstalling Windows 10 Update Assistant...
  135. %systemdrive%\Windows10Upgrade\Windows10UpgraderApp.exe /forceuninstall
  136. timeout /t 10 /nobreak
  137. cls)
  138. ::::::::::::::::::::::::::::
  139. echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.
  140. echo. & echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Initializing script...
  141. ::::::::::::::::::::::::::::
  142. ::Disable update service.
  143. call :wuauserv d
  144. ::::::::::::::::::::::::::::
  145. cls
  146. echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.
  147. echo. & echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Initializing script...
  148. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Creating Tasks...
  149. ::::::::::::::::::::::::::::::::::
  150. schtasks /delete /tn WDU >nul /f 2>&1
  151. schtasks /delete /tn Wub_task /f >nul 2>&1
  152. schtasks /Delete /Tn \Microsoft\WuWrapperScript\WDU /f >nul 2>&1
  153. schtasks /Delete /Tn \Microsoft\WuWrapperScript\Wub_task /f >nul 2>&1
  154. rmdir %SystemDrive%\Windows\System32\Tasks\Microsoft\WuWrapperScript /s /q >nul 2>&1
  155. %nsudovar% -ShowWindowMode:Hide -Wait -U:T -P:E reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Microsoft\WuWrapperScript" /f >nul 2>&1
  156. schtasks /Delete /Tn \Microsoft\Sledgehammer\WDU /f >nul 2>&1
  157. schtasks /Delete /Tn \Microsoft\Sledgehammer\Wub_task /f >nul 2>&1
  158. schtasks /Delete /Tn \Microsoft\Sledgehammer\LockFiles /f >nul 2>&1
  159. rmdir %SystemDrive%\Windows\System32\Tasks\Microsoft\Sledgehammer /s /q >nul 2>&1
  160. %nsudovar% -ShowWindowMode:Hide -Wait -U:T -P:E reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Microsoft\Sledgehammer" /f >nul 2>&1
  161. ::::::::::::::::::::::::::::
  162. takeown /f "%systemroot%\UpdateAssistant" /a >nul 2>&1
  163. icacls "%systemroot%\UpdateAssistant" /reset >nul 2>&1
  164. del %systemroot%\UpdateAssistant\*.* /f /q >nul 2>&1
  165. rmdir %systemroot%\UpdateAssistant /s /q >nul 2>&1
  166. md "%systemroot%\UpdateAssistant" >nul 2>&1
  167. attrib +s +h "%systemroot%\UpdateAssistant" >nul 2>&1
  168. %nsudovar% -ShowWindowMode:Hide -Wait -U:T -P:E "%systemroot%\System32\icacls.exe" %systemroot%\UpdateAssistant /inheritance:r /remove:g *S-1-5-32-544 *S-1-5-11 *S-1-5-32-545 *S-1-5-18 >nul 2>&1
  169. takeown /f "%systemroot%\UpdateAssistantV2" /a >nul 2>&1
  170. icacls "%systemroot%\UpdateAssistantV2" /reset >nul 2>&1
  171. del %systemroot%\UpdateAssistantV2\*.* /f /q >nul 2>&1
  172. md "%systemroot%\UpdateAssistantV2" >nul 2>&1
  173. attrib +s +h "%systemroot%\UpdateAssistantV2" >nul 2>&1
  174. %nsudovar% -ShowWindowMode:Hide -Wait -U:T -P:E "%systemroot%\System32\icacls.exe" %systemroot%\UpdateAssistantV2 /inheritance:r /remove:g *S-1-5-32-544 *S-1-5-11 *S-1-5-32-545 *S-1-5-18 >nul 2>&1
  175. takeown /f "%SystemDrive%\Windows10Upgrade" /a >nul 2>&1
  176. icacls "%SystemDrive%\Windows10Upgrade" /reset >nul 2>&1
  177. del %SystemDrive%\Windows10Upgrade\*.* /f /q >nul 2>&1
  178. rmdir %SystemDrive%\Windows10Upgrade /s /q >nul 2>&1
  179. md "%systemdrive%\Windows10Upgrade" >nul 2>&1
  180. attrib +s +h %systemdrive%\Windows10Upgrade >nul 2>&1
  181. %nsudovar% -ShowWindowMode:Hide -Wait -U:T -P:E "%systemroot%\System32\icacls.exe" %systemdrive%\Windows10Upgrade /inheritance:r /remove:g *S-1-5-32-544 *S-1-5-11 *S-1-5-32-545 *S-1-5-18 >nul 2>&1
  182. ::::::::::::::::::::::::::::
  183. ::Disable rempl
  184. if not exist "%ProgramFiles%\rempl" goto norempl
  185. takeown /f "%ProgramFiles%\rempl" /a >nul 2>&1
  186. icacls "%ProgramFiles%\rempl" /reset >nul 2>&1
  187. for %%? in ("%ProgramFiles%\rempl\*") do (
  188. takeown /f "%%?" /a >nul 2>&1
  189. icacls "%%?" /reset >nul 2>&1
  190. )
  191. del %ProgramFiles%\rempl\*.* /f /q >nul 2>&1
  192. rmdir %ProgramFiles%\rempl /s /q >nul 2>&1
  193. :norempl
  194. ::The rempl folder doesn't exist, so create it and lock it from system access.
  195. md "%ProgramFiles%\rempl" >nul 2>&1
  196. attrib +s +h "%ProgramFiles%\rempl" >nul 2>&1
  197. %nsudovar% -ShowWindowMode:Hide -Wait -U:T -P:E "%systemroot%\System32\icacls.exe" "%ProgramFiles%\rempl" /inheritance:r /remove:g *S-1-5-32-544 *S-1-5-11 *S-1-5-32-545 *S-1-5-18 >nul 2>&1
  198. ::::::::::::::::::::::::::::
  199. :: Disable all Language Components Installer tasks
  200. takeown /f "%systemroot%\System32\Tasks\Microsoft\Windows\LanguageComponentsInstaller\*" /a >nul 2>&1
  201. icacls "%systemroot%\System32\Tasks\Microsoft\Windows\LanguageComponentsInstaller\*" /q /c /t /reset >nul 2>&1
  202. for %%? in ("%systemroot%\System32\Tasks\Microsoft\Windows\LanguageComponentsInstaller\*") do schtasks /change /tn "Microsoft\Windows\LanguageComponentsInstaller\%%~nx?" /disable >nul 2>&1
  203. ::::::::::::::::::::::::::::
  204. cls
  205. echo.&echo.&echo.
  206. rem echo.
  207. rem echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  208. rem echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ : ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Sledgehammer - Windows 10 Update Control ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ :
  209. rem echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  210. rem for /f "tokens=15,* delims=/.-" %%a in ('curl -s https://www.askwoody.com^|findstr "\/MS-DEFCON-.\.jpg"') do echo ^ ^ ^
  211. rem ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ MS-DEFCON = %%a
  212. rem powershell "(curl.exe -s https://www.askwoody.com)|foreach{If($_ -cmatch '\/MS-DEFCON-\d\.jpg'){\"`r`n MS-DEFCON = \"+($_ -csplit '\/MS-DEFCON-',2)[1].substring(0,1)+\"`r`n`r`n\";exit}};\"`r`nUnable to retrieve MS-DEFCON rating from askwoody.com\""
  213. rem echo.&echo.&echo.
  214. echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.
  215. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Initializing script...
  216. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Creating Tasks...
  217. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Disabling update service...
  218. ::::::::::::::::::::::::::::
  219. :: Disable and lock all Windows Update tasks.
  220. takeown /f "%systemroot%\System32\Tasks\Microsoft\Windows\WindowsUpdate\*" /a >nul 2>&1
  221. icacls "%systemroot%\System32\Tasks\Microsoft\Windows\WindowsUpdate\*" /q /c /t /reset >nul 2>&1
  222. for %%? in ("%systemroot%\System32\Tasks\Microsoft\Windows\WindowsUpdate\*") do schtasks /change /tn "Microsoft\Windows\WindowsUpdate\%%~nx?" /disable >nul 2>&1
  223. icacls "%systemroot%\System32\Tasks\Microsoft\Windows\WindowsUpdate\*" /inheritance:r /remove *S-1-5-32-544 *S-1-5-11 *S-1-5-32-545 *S-1-5-18 >nul 2>&1
  224. ::::::::::::::::::::::::::::
  225. ::Set list (s32list) of update hijacker files to be disabled, then disable everything in the list.
  226. set s32list=EOSNotify.exe WaaSMedic.exe WaasMedicSvc.dll WaaSMedicPS.dll WaaSAssessment.dll UsoClient.exe
  227. set s32list=%s32list% SIHClient.exe MusNotificationUx.exe MusNotification.exe osrss.dll
  228. set s32=%systemroot%\System32
  229. ::If "s32list" files were previously renamed by script, restore original file names
  230. for %%# in (%s32list%) do (
  231. ren "%s32%\%%#"-backup "%%#" >nul 2>&1
  232. if exist "%s32%\%%#" del "%s32%\%%#"-backup /f /q >nul 2>&1
  233. )
  234. ::Lock files
  235. for %%# in (%s32list%) do (
  236. takeown /f "%s32%\%%#" /a >nul 2>&1
  237. icacls "%s32%\%%#" /reset >nul 2>&1
  238. if exist "%s32%\%%#" %nsudovar% -ShowWindowMode:Hide -Wait -U:T -P:E "%systemroot%\System32\icacls.exe" "%s32%\%%#" /inheritance:r /remove *S-1-5-32-544 *S-1-5-11 *S-1-5-32-545 *S-1-5-18 >nul 2>&1
  239. )
  240. ::If files in "s32list" aren't locked for whatever reason, rename them.
  241. for %%# in (%s32list%) do (
  242. ren "%s32%\%%#" "%%#"-backup >nul 2>&1
  243. if exist "%s32%\%%#"-backup del "%s32%\%%#" /f /q >nul 2>&1
  244. )
  245. ::::::::::::::::::::::::::::
  246. ::Create WDU task, wub_task, and LockFiles task
  247. call :create_task WDU "Windows Defender Update"
  248. call :create_task Wub_task "Windows Update Blocker Auto-Renewal"
  249. call :create_task LockFiles "Lock system update hijacker files"
  250. ::::::::::::::::::::::::::::
  251. echo.&echo.&echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Windows 10 updates disabled.
  252. rem echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Windows 10 updates disabled.
  253. rem echo.&echo.&echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Close window ^(click "X"^) if done.
  254. echo.&echo.&echo.&echo.
  255. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Press a key to continue and check for updates...
  256. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Close window ^(click "X"^) if done.
  257. pause >nul 2>&1
  258. :splash
  259. cls
  260. echo.
  261. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ::::::::::::::::::::::::::::::::
  262. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ : ^ Welcome to manual updates! ^ :
  263. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ::::::::::::::::::::::::::::::::
  264. echo.
  265. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ The Windows Update Service is now DISABLED and stopped.
  266. echo ^ ^ The tasks "WDU" (Windows Defender Update), "wub_task" and "LockFiles" (Forces Update
  267. echo ^ ^ ^ ^ ^ ^ ^ ^ service off and locks files) have been (re)created.
  268. echo.
  269. echo ^ * ^ Update Hijackers are now disabled! (see readme for details)
  270. echo ^ * ^ If you just want to disable the Update Hijackers and not check for or install
  271. echo ^ ^ ^ ^ updates, you may close this screen now.
  272. echo.
  273. echo ^ * ^ If you choose to review any available Windows updates, the script enables and
  274. echo ^ ^ ^ ^ starts only the Windows Update Service, then runs the Windows update Manager
  275. echo ^ ^ ^ ^ (WuMgr) or the Windows Update MiniTool (WUMT) to find and then hide or install
  276. echo ^ ^ ^ ^ selected Windows updates. If you run WUMT, don't change WUMT settings while
  277. echo ^ ^ ^ ^ running this script. If WuMgr or WUMT is offering updates, you need to hide or
  278. echo ^ ^ ^ ^ install them before closing WuMgr or WUMT.
  279. echo.
  280. echo ^ * ^ After checking for updates, the script stops and disables the Windows Update service
  281. echo ^ ^ ^ ^ when WuMgr or WUMT is closed whether or not the service was previously enabled.
  282. echo.
  283. echo ^ * ^ If you choose to use the Store, you can enable update service in Configurator.
  284. echo ^ ^ ^ ^ After using the Store, then either 1) disable update service or 2) continue script to
  285. echo ^ ^ ^ ^ check for Windows updates with WuMgr or WUMT after which the update service will be
  286. echo ^ ^ ^ ^ disabled.
  287. echo.
  288. echo ^ * ^ If you move this script to another folder run it again so the tasks will work!
  289. echo.
  290. echo ^ * ^ The included uninstaller undoes script changes.
  291. echo.&echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ---^>^>^> Press any key to continue. ^<^<^<---
  292. pause > nul
  293. ::::::::::::::::::::::::::::
  294. ::Internet connection check
  295. cls
  296. set divider=:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  297. powershell -nologo "If([Activator]::CreateInstance([Type]::GetTypeFromCLSID([Guid]'{DCB00C01-570F-4A9B-8D69-199FDBA5723B}')).IsConnectedToInternet){Exit 0}Else{Exit 1}"
  298. if %errorlevel%==0 (goto postinternetcheck)
  299. :internetcheckerror
  300. cls
  301. echo.&echo.&echo.&echo.&echo.&echo.
  302. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Internet connection test failed. &echo.&echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Microsoft Store or Windows Updates won't work without internet. &echo.&echo. & echo %divider% & echo.&echo.&echo. ^ ^ ^ ^ ^ ^ ^ ---^>^>^> Press a key to continue if you're sure internet is working. ^<^<^<--- & echo.&echo. & echo %divider% & echo.&echo ^ ^ It's safe to cancel now if needed. Your system will not be left in an unstable state.&echo.&echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^(Ctrl-C, Alt-F4, or click "X" to cancel and exit^)&echo. & pause > nul
  303. :postinternetcheck
  304. ::::::::::::::::::::::::::::
  305. ::Windows Update Service Configurator
  306. cls
  307. echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.
  308. echo. & echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Initializing Configurator...
  309. ::disable windows update service except when wumt is run.
  310. :wudisable
  311. timeout -t 1 > nul
  312. call :wuauserv d
  313. cls
  314. echo.
  315. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  316. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ : ^ ^ ^ ^ Sledgehammer - Windows 10 Update Control Configurator ^ ^ ^ ^ :
  317. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  318. echo.
  319. echo ^ ^ ^ ^ ^ ^ ^ ^ ---^>^>^> Windows Update Service is DISABLED and stopped ^(default^) ^<^<^<---
  320. echo.
  321. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ [E]nable Update Service temporarily to use Windows Store.
  322. echo.
  323. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ [1] Continue script to run Windows Update Manager (WuMgr)
  324. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ in auto mode and check for Windows Updates.
  325. echo.
  326. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ [2] Continue script to run Windows Update Minitool (WUMT)
  327. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ in auto mode and check for Windows Updates.
  328. echo.
  329. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ [3] Continue script to run Windows Update Manager (WuMgr)
  330. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ in automatic Offline Mode. *Warning: Wsusscn2.cab is
  331. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ over 500 MB. Download will start immediately.*
  332. echo.
  333. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ [4] Continue script to run Windows Update Manager (WuMgr)
  334. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ in Expert Mode.
  335. echo.
  336. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ [Q]uit script, or "Alt + F4", or close window, if you're
  337. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ just verifying or are finished changing the update
  338. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ service setting. It stays how it's set above.
  339. echo.
  340. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ The Windows Update service will be automatically
  341. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ started and stopped.
  342. echo.&echo.
  343. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Please select [E], [1], [2], [3], [4], or [Q]
  344. CHOICE /C E1234Q /M "Your choice?:" >nul 2>&1
  345. if %errorlevel%==6 (exit)
  346. if %errorlevel%==5 call :startupdate bin\wumgr.exe 7971f918-a847-4430-9279-4a52d1efe18d -onclose close.cmd >nul 2>&1
  347. if %errorlevel%==4 call :startupdate bin\wumgr.exe -update -offline 7971f918-a847-4430-9279-4a52d1efe18d -onclose close.cmd >nul 2>&1
  348. if %errorlevel%==3 call :StartUpdate %wumt% -update "-onclose close.cmd" >nul 2>&1
  349. if %errorlevel%==2 call :StartUpdate bin\wumgr.exe -update -online 7971f918-a847-4430-9279-4a52d1efe18d -provisioned -onclose close.cmd >nul 2>&1
  350. cls
  351. echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.
  352. echo.&echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Please wait while Windows Update Service is enabled...
  353. ::enable windows update service
  354. :wuenable
  355. call :wuauserv e
  356. cls
  357. echo.&echo.
  358. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  359. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ : ^ ^ ^ ^ Sledgehammer - Windows 10 Update Control Configurator ^ ^ ^ ^ :
  360. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  361. echo.
  362. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ---^>^>^> Windows Update Service is ENABLED ^(for Store^) ^<^<^<---
  363. echo.
  364. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ [D]isable Update Service when finished using Store.
  365. echo.
  366. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ [1] Continue script to run Windows Update Manager (WuMgr)
  367. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ in auto mode and check for Windows Updates.
  368. echo.
  369. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ [2] Continue script to run Windows Update Minitool (WUMT)
  370. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ in auto mode and check for Windows Updates.
  371. echo.
  372. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ [3] Continue script to run Windows Update Manager (WuMgr)
  373. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ in automatic Offline Mode. *Warning: Wsusscn2.cab is
  374. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ over 500 MB. Download will start immediately.*
  375. echo.
  376. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ [4] Continue script to run Windows Update Manager (WuMgr)
  377. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ in Expert Mode.
  378. echo.
  379. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ The Windows Update service will be automatically
  380. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ started and stopped.
  381. echo.
  382. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Please select [D], [1], [2], [3], or [4]
  383. echo.
  384. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  385. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ :^ Don't close this window or update service will stay on!!!^ :
  386. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ : ^ ^ Don't worry. Just run the script again to turn it off ^ ^ :
  387. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  388. CHOICE /C D1234 /M "Your choice?:" >nul 2>&1
  389. if %errorlevel%==5 call :startupdate bin\wumgr.exe 7971f918-a847-4430-9279-4a52d1efe18d -onclose close.cmd >nul 2>&1
  390. if %errorlevel%==4 call :startupdate bin\wumgr.exe -update -offline 7971f918-a847-4430-9279-4a52d1efe18d -onclose close.cmd >nul 2>&1
  391. if %errorlevel%==3 call :StartUpdate %wumt% -update "-onclose close.cmd" >nul 2>&1
  392. if %errorlevel%==2 call :StartUpdate bin\wumgr.exe -update -online 7971f918-a847-4430-9279-4a52d1efe18d -provisioned -onclose close.cmd >nul 2>&1
  393. if %errorlevel%==1 (
  394. cls
  395. echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.
  396. echo.&echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Please wait while Windows Update Service is disabled...
  397. goto wudisable
  398. )
  399. ::::::::::::::::::::::::::::
  400. :create_task
  401. copy bin\%1.vbs task.vbs >nul & task.vbs
  402. schtasks /delete /tn "%1" /f >nul 2>&1
  403. schtasks /create /tn "\Microsoft\Sledgehammer\%1" /ru "SYSTEM" /xml task.xml /F >nul 2>&1 || (
  404. cls&echo.&echo Creating %3 %2 %1 task errored.&echo.&echo.&echo Press any key to exit... & pause > nul &exit)
  405. del task.vbs task.xml >nul 2>&1
  406. exit /b
  407. ::::::::::::::::::::::::::::
  408. :wuauserv
  409. if /i "%1"=="e" (set "wub=wub.exe /e" & set "status=True" & %UpdateSettingsShow%) else (set "wub=wub.exe /d /p" & set "status=False" & %UpdateSettingsHide%)
  410. .\bin\%wub%
  411. timeout -t 2 > nul
  412. set /a "max_retry=10" & set /a "i=0"
  413. :wuauserv1
  414. if %i%==%max_retry% (echo Operation did not complete within %max_retry% s. Press any key do exit...&pause>nul&exit)
  415. set /a "i+=1"
  416. WMIC Service WHERE "Name = 'Wuauserv'" GET Started | find /i "%status%" >nul && exit /b || (timeout /t 1 >nul & goto :wuauserv1)
  417. ::::::::::::::::::::::::::::
  418. :StartUpdate
  419. (
  420. echo @echo off
  421. echo :loop
  422. echo net start wuauserv
  423. echo timeout /t 10
  424. echo goto loop
  425. )>WU-keep-alive.cmd
  426. (
  427. echo @echo off
  428. echo cd /d "%%~dp0"
  429. echo del WU-keep-alive.cmd
  430. echo .\bin\wub.exe /d /p
  431. echo reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer /v SettingsPageVisibility /d hide:windowsupdate /f
  432. echo del close.cmd ^& exit
  433. )>close.cmd
  434. call :wuauserv e
  435. echo CreateObject^("WScript.Shell"^).Run "WU-keep-alive.cmd",0 >WU-keep-alive.vbs&WU-keep-alive.vbs&del WU-keep-alive.vbs
  436. Start "" %*
  437. exit
Advertisement
Add Comment
Please, Sign In to add comment