pf100

v2.7.1rc2Sledgehammer.cmd

May 26th, 2020
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.85 KB | None | 0 0
  1. @echo off
  2. mode con cols=89 lines=34
  3. Title Sledgehammer 2.7.1
  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. ::Remove and/or lock Update Assistant
  125. if exist "%systemdrive%\Windows10Upgrade\Windows10UpgraderApp.exe" ( echo Windows 10 Update Assistant detected. Preparing to uninstall.
  126. echo The "Windows 10 Update Assistant has stopped working" dialog box may pop up.
  127. echo If so, just close it.
  128. echo.& echo Press a key to acknowledge this and please wait for the uninstall to finish.
  129. echo Script will continue after uninstall and removal is completed...
  130. pause > nul
  131. echo Uninstalling Windows 10 Update Assistant...
  132. %systemdrive%\Windows10Upgrade\Windows10UpgraderApp.exe /forceuninstall
  133. timeout /t 10 /nobreak
  134. cls)
  135. ::::::::::::::::::::::::::::
  136. :: Get MS-Defcon from askwoody.com
  137. powershell -Nologo -NoProfile -ExecutionPolicy Bypass .\bin\awmsdc.ps1
  138. ::::::::::::::::::::::::::::
  139. echo Disabling update hijackers...
  140. echo Creating tasks...
  141. echo Disabling windows Update Service...
  142. echo. & echo :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  143. ::::::::::::::::::::::::::::
  144. ::Disable update service.
  145. call :wuauserv d
  146. ::::::::::::::::::::::::::::
  147. schtasks /delete /tn WDU >nul /f 2>&1
  148. schtasks /delete /tn Wub_task /f >nul 2>&1
  149. schtasks /Delete /Tn \Microsoft\WuWrapperScript\WDU /f >nul 2>&1
  150. schtasks /Delete /Tn \Microsoft\WuWrapperScript\Wub_task /f >nul 2>&1
  151. rmdir %SystemDrive%\Windows\System32\Tasks\Microsoft\WuWrapperScript /s /q >nul 2>&1
  152. %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
  153. schtasks /Delete /Tn \Microsoft\Sledgehammer\WDU /f >nul 2>&1
  154. schtasks /Delete /Tn \Microsoft\Sledgehammer\Wub_task /f >nul 2>&1
  155. schtasks /Delete /Tn \Microsoft\Sledgehammer\LockFiles /f >nul 2>&1
  156. rmdir %SystemDrive%\Windows\System32\Tasks\Microsoft\Sledgehammer /s /q >nul 2>&1
  157. %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
  158. ::::::::::::::::::::::::::::::::::
  159. takeown /f "%systemroot%\UpdateAssistant" /a >nul 2>&1
  160. icacls "%systemroot%\UpdateAssistant" /reset >nul 2>&1
  161. del %systemroot%\UpdateAssistant\*.* /f /q >nul 2>&1
  162. rmdir %systemroot%\UpdateAssistant /s /q >nul 2>&1
  163. md "%systemroot%\UpdateAssistant" >nul 2>&1
  164. attrib +s +h "%systemroot%\UpdateAssistant" >nul 2>&1
  165. %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
  166. takeown /f "%systemroot%\UpdateAssistantV2" /a >nul 2>&1
  167. icacls "%systemroot%\UpdateAssistantV2" /reset >nul 2>&1
  168. del %systemroot%\UpdateAssistantV2\*.* /f /q >nul 2>&1
  169. md "%systemroot%\UpdateAssistantV2" >nul 2>&1
  170. attrib +s +h "%systemroot%\UpdateAssistantV2" >nul 2>&1
  171. %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
  172. takeown /f "%SystemDrive%\Windows10Upgrade" /a >nul 2>&1
  173. icacls "%SystemDrive%\Windows10Upgrade" /reset >nul 2>&1
  174. del %SystemDrive%\Windows10Upgrade\*.* /f /q >nul 2>&1
  175. rmdir %SystemDrive%\Windows10Upgrade /s /q >nul 2>&1
  176. md "%systemdrive%\Windows10Upgrade" >nul 2>&1
  177. attrib +s +h %systemdrive%\Windows10Upgrade >nul 2>&1
  178. %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
  179. ::::::::::::::::::::::::::::
  180. ::Disable rempl
  181. if not exist "%ProgramFiles%\rempl" goto norempl
  182. takeown /f "%ProgramFiles%\rempl" /a >nul 2>&1
  183. icacls "%ProgramFiles%\rempl" /reset >nul 2>&1
  184. for %%? in ("%ProgramFiles%\rempl\*") do (
  185. takeown /f "%%?" /a >nul 2>&1
  186. icacls "%%?" /reset >nul 2>&1
  187. )
  188. del %ProgramFiles%\rempl\*.* /f /q >nul 2>&1
  189. rmdir %ProgramFiles%\rempl /s /q >nul 2>&1
  190. :norempl
  191. ::The rempl folder doesn't exist, so create it and lock it from system access.
  192. md "%ProgramFiles%\rempl" >nul 2>&1
  193. attrib +s +h "%ProgramFiles%\rempl" >nul 2>&1
  194. %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
  195. ::::::::::::::::::::::::::::
  196. :: Disable all Language Components Installer tasks
  197. takeown /f "%systemroot%\System32\Tasks\Microsoft\Windows\LanguageComponentsInstaller\*" /a >nul 2>&1
  198. icacls "%systemroot%\System32\Tasks\Microsoft\Windows\LanguageComponentsInstaller\*" /q /c /t /reset >nul 2>&1
  199. for %%? in ("%systemroot%\System32\Tasks\Microsoft\Windows\LanguageComponentsInstaller\*") do schtasks /change /tn "Microsoft\Windows\LanguageComponentsInstaller\%%~nx?" /disable >nul 2>&1
  200. ::::::::::::::::::::::::::::
  201. :: Disable and lock all Windows Update tasks.
  202. takeown /f "%systemroot%\System32\Tasks\Microsoft\Windows\WindowsUpdate\*" /a >nul 2>&1
  203. icacls "%systemroot%\System32\Tasks\Microsoft\Windows\WindowsUpdate\*" /q /c /t /reset >nul 2>&1
  204. for %%? in ("%systemroot%\System32\Tasks\Microsoft\Windows\WindowsUpdate\*") do schtasks /change /tn "Microsoft\Windows\WindowsUpdate\%%~nx?" /disable >nul 2>&1
  205. 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
  206. ::::::::::::::::::::::::::::
  207. ::Set list (s32list) of update hijacker files to be disabled, then disable everything in the list.
  208. set s32list=EOSNotify.exe WaaSMedic.exe WaasMedicSvc.dll WaaSMedicPS.dll WaaSAssessment.dll UsoClient.exe
  209. set s32list=%s32list% SIHClient.exe MusNotificationUx.exe MusNotification.exe osrss.dll
  210. set s32=%systemroot%\System32
  211. ::If "s32list" files were previously renamed by script, restore original file names
  212. for %%# in (%s32list%) do (
  213. ren "%s32%\%%#"-backup "%%#" >nul 2>&1
  214. if exist "%s32%\%%#" del "%s32%\%%#"-backup /f /q >nul 2>&1
  215. )
  216. ::Lock files
  217. for %%# in (%s32list%) do (
  218. takeown /f "%s32%\%%#" /a >nul 2>&1
  219. icacls "%s32%\%%#" /reset >nul 2>&1
  220. 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
  221. )
  222. ::If files in "s32list" aren't locked for whatever reason, rename them.
  223. for %%# in (%s32list%) do (
  224. ren "%s32%\%%#" "%%#"-backup >nul 2>&1
  225. if exist "%s32%\%%#"-backup del "%s32%\%%#" /f /q >nul 2>&1
  226. )
  227. ::::::::::::::::::::::::::::
  228. :: Create WDU.cmd
  229. (
  230. echo ::Allow only WDU task to run this file::
  231. echo whoami /user /nh ^| find /i "S-1-5-18" ^|^| exit
  232. echo cd /d "%%~dp0"
  233. echo ::Wait 5 minutes to prevent resource hogging after reboot with missed update::
  234. echo timeout /t 300^>nul
  235. echo ::If WUMT or WuMgr are running, cancel Defender update and exit. If not, continue::
  236. echo tasklist ^| findstr /i "wumt_x86.exe wumt_x64.exe wumgr.exe" ^&^& exit 1
  237. echo ::If Windows Defender is running, update it. If not, cancel Defender update and exit::
  238. echo sc query ^| find /i "windefend" ^|^| exit 1
  239. echo ::Enable Windows Update service and update Defender, then disable Update Service::
  240. echo wub.exe /e
  241. echo timeout /t 10
  242. echo "%%ProgramFiles%%\Windows Defender\MpCmdRun.exe" -SignatureUpdate
  243. echo wub.exe /d /p
  244. echo exit /b %%errorlevel%%
  245. )>.\bin\wdu.cmd"
  246. ::::::::::::::::::::::::::::
  247. ::Create WDU task, wub_task, and LockFiles task
  248. call :create_task WDU "Windows Defender Update"
  249. call :create_task Wub_task "Windows Update Blocker Auto-Renewal"
  250. call :create_task LockFiles "Lock system update hijacker files"
  251. ::::::::::::::::::::::::::::
  252. echo.&echo Windows 10 updates disabled.
  253. echo Close window ^(click "X"^) if done, or press a key to check for updates...
  254. pause >nul 2>&1
  255. :splash
  256. cls
  257. echo.
  258. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ::::::::::::::::::::::::::::::::
  259. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ : ^ Welcome to manual updates! ^ :
  260. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ::::::::::::::::::::::::::::::::
  261. echo.
  262. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ The Windows Update Service is now DISABLED and stopped.
  263. echo ^ ^ The tasks "WDU" (Windows Defender Update) and "wub_task" (Forces Update service off
  264. echo ^ ^ ^ ^ ^ ^ ^ ^ after reboot and login) have been (re)created.
  265. echo.
  266. echo ^ * ^ Update Hijackers are now disabled! (see readme for details)
  267. echo ^ * ^ If you just want to disable the Update Hijackers and not check for or install
  268. echo ^ ^ ^ ^ updates, you may close this screen now.
  269. echo.
  270. echo ^ * ^ If you choose to review any available Windows updates, the script enables and
  271. echo ^ ^ ^ ^ starts only the Windows Update Service, then runs the Windows update Manager
  272. echo ^ ^ ^ ^ (WuMgr) or the Windows Update MiniTool (WUMT) to find and then hide or install
  273. echo ^ ^ ^ ^ selected Windows updates. If you run WUMT, don't change WUMT settings while
  274. echo ^ ^ ^ ^ running this script. If WuMgr or WUMT is offering updates, you need to hide or
  275. echo ^ ^ ^ ^ install them before closing WuMgr or WUMT.
  276. echo.
  277. echo ^ * ^ After checking for updates, the script stops and disables the Windows Update service
  278. echo ^ ^ ^ ^ when WuMgr or WUMT is closed whether or not the service was previously enabled.
  279. echo.
  280. echo ^ * ^ If you choose to use the Store, you can enable update service in Configurator.
  281. echo ^ ^ ^ ^ After using the Store, then either 1) disable update service or 2) continue script to
  282. echo ^ ^ ^ ^ check for Windows updates with WuMgr or WUMT after which the update service will be
  283. echo ^ ^ ^ ^ disabled.
  284. echo.
  285. echo ^ * ^ If you move this script to another folder run it again so the tasks will work!
  286. echo.
  287. echo ^ * ^ The included uninstaller undoes script changes.
  288. echo.&echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ---^>^>^> Press any key to continue. ^<^<^<---
  289. pause > nul
  290. ::::::::::::::::::::::::::::
  291. ::Internet connection check
  292. cls
  293. set divider=:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  294. powershell -nologo "If([Activator]::CreateInstance([Type]::GetTypeFromCLSID([Guid]'{DCB00C01-570F-4A9B-8D69-199FDBA5723B}')).IsConnectedToInternet){Exit 0}Else{Exit 1}"
  295. if %errorlevel%==0 (goto postinternetcheck)
  296. :internetcheckerror
  297. cls
  298. echo.&echo.&echo.&echo.&echo.&echo.
  299. 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
  300. :postinternetcheck
  301. ::::::::::::::::::::::::::::
  302. ::Windows Update Service Configurator
  303. cls
  304. echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.
  305. echo. & echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Initializing Configurator...
  306. ::disable windows update service except when wumt is run.
  307. :wudisable
  308. timeout -t 1 > nul
  309. call :wuauserv d
  310. cls
  311. echo.
  312. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  313. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ : ^ ^ ^ ^ Sledgehammer - Windows 10 Update Control Configurator ^ ^ ^ ^ :
  314. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  315. echo.
  316. echo ^ ^ ^ ^ ^ ^ ^ ^ ---^>^>^> Windows Update Service is DISABLED and stopped ^(default^) ^<^<^<---
  317. echo.
  318. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ [E]nable Update Service temporarily to use Windows Store.
  319. echo.
  320. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ [1] Continue script to run Windows Update Manager (WuMgr)
  321. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ in auto mode and check for Windows Updates.
  322. echo.
  323. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ [2] Continue script to run Windows Update Minitool (WUMT)
  324. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ in auto mode and check for Windows Updates.
  325. echo.
  326. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ [3] Continue script to run Windows Update Manager (WuMgr)
  327. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ in automatic Offline Mode. *Warning: Wsusscn2.cab is
  328. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ over 500 MB. Download will start immediately.*
  329. echo.
  330. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ [4] Continue script to run Windows Update Manager (WuMgr)
  331. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ in Expert Mode.
  332. echo.
  333. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ [Q]uit script, or "Alt + F4", or close window, if you're
  334. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ just verifying or are finished changing the update
  335. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ service setting. It stays how it's set above.
  336. echo.
  337. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ The Windows Update service will be automatically
  338. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ started and stopped.
  339. echo.&echo.
  340. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Please select [E], [1], [2], [3], [4], or [Q]
  341. CHOICE /C E1234Q /M "Your choice?:" >nul 2>&1
  342. if %errorlevel%==6 (exit)
  343. if %errorlevel%==5 call :startupdate bin\wumgr.exe 7971f918-a847-4430-9279-4a52d1efe18d -onclose close.cmd >nul 2>&1
  344. if %errorlevel%==4 call :startupdate bin\wumgr.exe -update -offline 7971f918-a847-4430-9279-4a52d1efe18d -onclose close.cmd >nul 2>&1
  345. if %errorlevel%==3 call :StartUpdate %wumt% -update "-onclose close.cmd" >nul 2>&1
  346. if %errorlevel%==2 call :StartUpdate bin\wumgr.exe -update -online 7971f918-a847-4430-9279-4a52d1efe18d -provisioned -onclose close.cmd >nul 2>&1
  347. cls
  348. echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.
  349. echo.&echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Please wait while Windows Update Service is enabled...
  350. ::enable windows update service
  351. :wuenable
  352. call :wuauserv e
  353. cls
  354. echo.&echo.
  355. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  356. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ : ^ ^ ^ ^ Sledgehammer - Windows 10 Update Control Configurator ^ ^ ^ ^ :
  357. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  358. echo.
  359. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ---^>^>^> Windows Update Service is ENABLED ^(for Store^) ^<^<^<---
  360. echo.
  361. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ [D]isable Update Service when finished using Store.
  362. echo.
  363. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ [1] Continue script to run Windows Update Manager (WuMgr)
  364. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ in auto mode and check for Windows Updates.
  365. echo.
  366. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ [2] Continue script to run Windows Update Minitool (WUMT)
  367. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ in auto mode and check for Windows Updates.
  368. echo.
  369. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ [3] Continue script to run Windows Update Manager (WuMgr)
  370. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ in automatic Offline Mode. *Warning: Wsusscn2.cab is
  371. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ over 500 MB. Download will start immediately.*
  372. echo.
  373. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ [4] Continue script to run Windows Update Manager (WuMgr)
  374. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ in Expert Mode.
  375. echo.
  376. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ The Windows Update service will be automatically
  377. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ started and stopped.
  378. echo.
  379. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Please select [D], [1], [2], [3], or [4]
  380. echo.
  381. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  382. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ :^ Don't close this window or update service will stay on!!!^ :
  383. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ : ^ ^ Don't worry. Just run the script again to turn it off ^ ^ :
  384. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  385. CHOICE /C D1234 /M "Your choice?:" >nul 2>&1
  386. if %errorlevel%==5 call :startupdate bin\wumgr.exe 7971f918-a847-4430-9279-4a52d1efe18d -onclose close.cmd >nul 2>&1
  387. if %errorlevel%==4 call :startupdate bin\wumgr.exe -update -offline 7971f918-a847-4430-9279-4a52d1efe18d -onclose close.cmd >nul 2>&1
  388. if %errorlevel%==3 call :StartUpdate %wumt% -update "-onclose close.cmd" >nul 2>&1
  389. if %errorlevel%==2 call :StartUpdate bin\wumgr.exe -update -online 7971f918-a847-4430-9279-4a52d1efe18d -provisioned -onclose close.cmd >nul 2>&1
  390. if %errorlevel%==1 (
  391. cls
  392. echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.
  393. echo.&echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Please wait while Windows Update Service is disabled...
  394. goto wudisable
  395. )
  396. ::::::::::::::::::::::::::::
  397. :create_task
  398. copy bin\%1.vbs task.vbs >nul & task.vbs
  399. schtasks /delete /tn "%1" /f >nul 2>&1
  400. schtasks /create /tn "\Microsoft\Sledgehammer\%1" /ru "SYSTEM" /xml task.xml /F >nul 2>&1 || (
  401. cls&echo.&echo Creating %3 %2 %1 task errored.&echo.&echo.&echo Press any key to exit... & pause > nul &exit)
  402. del task.vbs task.xml >nul 2>&1
  403. exit /b
  404. ::::::::::::::::::::::::::::
  405. :wuauserv
  406. if /i "%1"=="e" (set "wub=wub.exe /e" & set "status=True") else (set "wub=wub.exe /d /p" & set "status=False")
  407. .\bin\%wub%
  408. timeout -t 2 > nul
  409. set /a "max_retry=10" & set /a "i=0"
  410. :wuauserv1
  411. if %i%==%max_retry% (echo Operation did not complete within %max_retry% s. Press any key do exit...&pause>nul&exit)
  412. set /a "i+=1"
  413. WMIC Service WHERE "Name = 'Wuauserv'" GET Started | find /i "%status%" >nul && exit /b || (timeout /t 1 >nul & goto :wuauserv1)
  414. ::::::::::::::::::::::::::::
  415. :StartUpdate
  416. (
  417. echo @echo off
  418. echo :loop
  419. echo net start wuauserv
  420. echo timeout /t 10
  421. echo goto loop
  422. )>WU-keep-alive.cmd
  423. (
  424. echo @echo off
  425. echo cd /d "%%~dp0"
  426. echo del WU-keep-alive.cmd
  427. echo .\bin\wub.exe /d /p
  428. echo del close.cmd ^& exit
  429. )>close.cmd
  430. call :wuauserv e
  431. echo CreateObject^("WScript.Shell"^).Run "WU-keep-alive.cmd",0 >WU-keep-alive.vbs&WU-keep-alive.vbs&del WU-keep-alive.vbs
  432. Start "" %*
  433. exit
Advertisement
Add Comment
Please, Sign In to add comment