Advertisement
pf100

v2.6.0Sledgehammer.cmd

Jul 7th, 2019
852
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 29.54 KB | None | 0 0
  1. @echo off
  2. mode con cols=89 lines=34
  3. Title Sledgehammer 2.6.0
  4. Color 1F & goto start
  5. Original script by pf100 @ MDL with special thanks to rpo and abbodi1406 @ MDL for code improvements.
  6. Project page and source code:
  7. https://forums.mydigitallife.net/threads/sledgehammer-windows-10-update-control.72203/
  8. ******************************************************************
  9. You may freely modify this script as you wish, I only request that you leave the credits and the
  10. link to the original script.
  11. ******************************************************************
  12. Don't move this script to another folder without running it again or the tasks won't work!
  13. This script provides manual updating for Windows 10 including Home versions.
  14. Update Windows 10 on your schedule, not Microsoft's!
  15. I originally wrote this script for personal use because of the lack of update options with the
  16. original RTM release of Windows 10 Pro. I wanted to update Windows 10 when I had the free time
  17. to manually update, just like I did with previous versions of Windows that allowed me to
  18. set updates to manual, not when Microsoft forced it on me while I was busy using my computer.
  19. *******************************************************************
  20. WUMT is available here: https://forums.mydigitallife.net/threads/64939-Windows-Update-MiniTool
  21. Windows Update Blocker is available here: http://sordum.org/files/windows-update-blocker/old/Wub_v1.0.zip
  22. Only use Windows Update Blocker v1.0 with this script, NOT v1.1!
  23. NSudo is available here: https://github.com/M2Team/NSudo/releases/tag/6.1
  24. *******************************************************************
  25. How it works: The script first checks if the OS is Windows 8.1 or older and if so
  26. it notifies the user, then exits. Windows 10 only!
  27. This script creates a smart Windows Defender Update task "WDU" that updates Windows
  28. Defender every 6 hours if it's running and enabled, and doesn't update it if it's not
  29. running and disabled, saving resources; auto-elevates, uninstalls and removes the
  30. Windows 10 Update Assistant, disables everything in the %programfiles%\rempl folder, resets and
  31. removes permissions from and disables these Update Hijackers:
  32. EOSNotify.exe
  33. WaaSMedic.exe
  34. WaasMedicSvc.dll
  35. WaaSMedicPS.dll
  36. WaaSAssessment.dll
  37. UsoClient.exe
  38. SIHClient.exe
  39. MusNotificationUx.exe
  40. MusNotification.exe
  41. osrss.dll
  42. %ProgramFiles%\rempl
  43. %systemroot%\UpdateAssistant
  44. %systemroot%\UpdateAssistantV2
  45. %systemdrive%\Windows10Upgrade
  46. disables all WindowsUpdate tasks
  47. makes sure the task "wub_task" is installed that runs wub at boot (to stop updates from turning
  48. updates back on), runs wub.exe and enables and starts the windows update service (wuauserv) if
  49. disabled, installs "WDU" Windows Defender Update task that runs every 2 hours (but doesn't update
  50. Defender if Defender is disabled), then runs the correct version of the Windows Update MiniTool in
  51. "auto search for updates" mode for your OS version's architecture (x86 or x64), then disables and
  52. stops wuauserv giving you full control. No more forced automatic updates or surprise reboots.
  53. This was written for Windows 10 Pro and Home, but works with all versions of Windows 10. Don't
  54. change any settings in lower left of WUMT while running the script.
  55. *******************************************************************
  56. I also included an uninstaller.cmd that deletes the "WDU" and "wub_task" tasks, deletes the WDU.cmd
  57. file used by WDU task, restores the rempl folder, resets Update Hijacker permissions to how they
  58. were originally, renables "WindowsUpdate" tasks, and turns off wub (if enabled) which turns the windows update service on automatic
  59. again, undoing everything done by the script. If you uninstall after having used the installer the
  60. script files are removed also.
  61. *******************************************************************
  62. Configurator leaves the Update Hijackers disabled, but gives you the option of turning on the windows
  63. update service temporarily to use the Store or any other operation that requires the windows update
  64. service, such as some DISM operations, installing dotNet 3.5, App Updates, etc.
  65. *******************************************************************
  66. :start
  67. cd /d "%~dp0"
  68. :::::::::::::::::::::::::::::::::::::::::
  69. :: Automatically check & get admin rights
  70. :::::::::::::::::::::::::::::::::::::::::
  71. :: ECHO.
  72. :: ECHO =============================
  73. :: ECHO Running Admin shell
  74. :: ECHO =============================
  75. :: Check Privileges
  76. :: Get Privileges
  77. :: and
  78. :: Invoke UAC for Privilege Escalation
  79. :: Notify if error escalating
  80. :: and prevent looping if escalation fails
  81. ::::::::::::::::::::::::::::
  82. set "params=Problem_with_elevating_UAC_for_Administrator_Privileges"&if exist "%temp%\getadmin.vbs" del "%temp%\getadmin.vbs"
  83. fsutil dirty query %systemdrive% >nul 2>&1 && goto :GotPrivileges
  84. :: The following test is to avoid infinite looping if elevating UAC for Administrator Privileges failed
  85. 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)
  86. cmd /u /c echo Set UAC = CreateObject^("Shell.Application"^) : UAC.ShellExecute "%~0", "%params%", "", "runas", 1 > "%temp%\getadmin.vbs"&cscript //nologo "%temp%\getadmin.vbs"&exit
  87. :GotPrivileges
  88. ::::::::::::::::::::::::::::
  89. ::Uninstall and remove Windows 10 Update assistant.
  90. ::Disable Windows Update Service until script menu screen.
  91. ::Reset (in case of wrong Permissions), remove Permissions from and
  92. ::disable "Update Hijackers"
  93. ::Install wub_task (prevents Windows Update service from starting after installing updates and rebooting).
  94. ::Install "WDU" task that only updates Defender if it's enabled. Otherwise it doesn't do anything.
  95. ::Enable and start the Windows Update Service (wuauserv).
  96. ::Run the correct version of WUMT for your architecture.
  97. ::Start WUMT in "auto-check for updates" mode.
  98. ::After updates are completed and WUMT is closed and/or the "reboot"
  99. ::button in WUMT is pressed, silently run wub.exe and disable and stop wuauserv
  100. ::::::::::::::::::::::::::::
  101. ::Test for Windows versions below Windows 10 and if so inform user, then exit...
  102. ::Get Windows OS build number
  103. for /f "tokens=2 delims==" %%a in ('wmic path Win32_OperatingSystem get BuildNumber /value') do (
  104. set /a WinBuild=%%a
  105. )
  106. if %winbuild% LEQ 9600 (
  107. echo.&echo This is not Windows 10. Press a key to exit...
  108. pause > nul
  109. exit
  110. )
  111. ::::::::::::::::::::::::::::
  112. ::Determine if running 32 or 64 bit Windows OS and set variables accordingly.
  113. wmic cpu get AddressWidth /value|find "32">nul&&set PROCESSOR_ARCHITECTURE=X86||set PROCESSOR_ARCHITECTURE=AMD64
  114. if %PROCESSOR_ARCHITECTURE%==AMD64 (
  115. set "nsudovar=.\bin\NSudoCx64.exe"
  116. set "wumt=.\bin\wumt_x64.exe"
  117. ) else (
  118. set "nsudovar=.\bin\NSudoc.exe"
  119. set "wumt=.\bin\wumt_x86.exe"
  120. )
  121. ::::::::::::::::::::::::::::
  122. ::Remove and/or lock Update Assistant
  123. if exist "%systemdrive%\Windows10Upgrade\Windows10UpgraderApp.exe" ( echo Windows 10 Update Assistant detected. Preparing to uninstall.
  124. echo The "Windows 10 Update Assistant has stopped working" dialog box may pop up.
  125. echo If so, just close it.
  126. echo.& echo Press a key to acknowledge this and please wait for the uninstall to finish.
  127. echo Script will continue after uninstall and removal is completed...
  128. pause > nul
  129. echo Uninstalling Windows 10 Update Assistant...
  130. %systemdrive%\Windows10Upgrade\Windows10UpgraderApp.exe /forceuninstall
  131. timeout /t 10 /nobreak
  132. cls)
  133. ::::::::::::::::::::::::::::
  134. (
  135. echo # Get MS-Defcon from askwoody.com
  136. echo $progressPreference = 'silentlyContinue'
  137. echo "`r`nAttempting to retrieve MS-DEFCON rating from askwoody.com...`r`n"
  138. echo Try {$WebResponse = Invoke-WebRequest "https://www.askwoody.com/" -UseBasicParsing} Catch {$WebResponse=""}
  139. echo clear-host
  140. echo if ^($WebResponse.Statuscode -ne 200^){write-host "Unable to retrieve MS-DEFCON rating from askwoody.com"; exit}
  141. echo ForEach ^($Image in $WebResponse.Images^) {
  142. echo $x = $Image.OuterHTML.ToString^(^)
  143. echo If ^($x -like "*MS-DEFCON-*"^) {
  144. echo "`r`nMS-DEFCON = " + $x.split^('/'^)[8].split^('.'^)[0].SubString^(10,1^)
  145. echo "`r`n::::::::::::::::::::::::::::"
  146. echo "`r`nMS-DEFCON 1: Current Microsoft patches are causing havoc. Don't patch.`r`n" + `
  147. echo "`r`nMS-DEFCON 2: Patch reliability is unclear. Unless you have an immediate, pressing need" + `
  148. echo "`r`n to install a specific patch, don't do it.`r`n" + `
  149. echo "`r`nMS-DEFCON 3: Patch reliability is unclear, but widespread attacks make patching prudent." + `
  150. echo "`r`n Go ahead and patch, but watch out for potential problems.`r`n" + `
  151. echo "`r`nMS-DEFCON 4: There are isolated problems with current patches, but they are well-known" + `
  152. echo "`r`n and documented here. Check this site to see if you're affected and if" + `
  153. echo "`r`n things look OK, go ahead and patch.`r`n" + `
  154. echo "`r`nMS-DEFCON 5: All's clear. Patch while it's safe.`r`n" + `
  155. echo "`r`nMore info at https://www.askwoody.com"
  156. echo exit
  157. echo }
  158. echo }
  159. )>"%temp%\awmsdc.ps1"
  160. PowerShell.exe -Nologo -NoProfile -ExecutionPolicy Bypass -command "%temp%\awmsdc.ps1"
  161. del "%temp%\awmsdc.ps1"
  162. ::::::::::::::::::::::::::::
  163. rem echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.
  164. echo.
  165. echo Disabling update hijackers...
  166. echo Creating tasks...
  167. echo Disabling windows Update Service...
  168. echo.
  169. ::::::::::::::::::::::::::::
  170. schtasks /delete /tn WDU >nul /f 2>&1
  171. schtasks /delete /tn Wub_task /f >nul 2>&1
  172. schtasks /Delete /Tn \Microsoft\WuWrapperScript\WDU /f >nul 2>&1
  173. schtasks /Delete /Tn \Microsoft\WuWrapperScript\Wub_task /f >nul 2>&1
  174. rmdir %SystemDrive%\Windows\System32\Tasks\Microsoft\WuWrapperScript /s /q >nul 2>&1
  175. %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
  176. schtasks /Delete /Tn \Microsoft\Sledgehammer\WDU /f >nul 2>&1
  177. schtasks /Delete /Tn \Microsoft\Sledgehammer\Wub_task /f >nul 2>&1
  178. rmdir %SystemDrive%\Windows\System32\Tasks\Microsoft\Sledgehammer /s /q >nul 2>&1
  179. %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
  180. ::::::::::::::::::::::::::::::::::
  181. takeown /f "%systemroot%\UpdateAssistant" /a >nul 2>&1
  182. icacls "%systemroot%\UpdateAssistant" /reset >nul 2>&1
  183. del %systemroot%\UpdateAssistant\*.* /f /q >nul 2>&1
  184. rmdir %systemroot%\UpdateAssistant /s /q >nul 2>&1
  185. md "%systemroot%\UpdateAssistant" >nul 2>&1
  186. attrib +s +h "%systemroot%\UpdateAssistant" >nul 2>&1
  187. %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
  188. takeown /f "%systemroot%\UpdateAssistantV2" /a >nul 2>&1
  189. icacls "%systemroot%\UpdateAssistantV2" /reset >nul 2>&1
  190. del %systemroot%\UpdateAssistantV2\*.* /f /q >nul 2>&1
  191. md "%systemroot%\UpdateAssistantV2" >nul 2>&1
  192. attrib +s +h "%systemroot%\UpdateAssistantV2" >nul 2>&1
  193. %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
  194. takeown /f "%SystemDrive%\Windows10Upgrade" /a >nul 2>&1
  195. icacls "%SystemDrive%\Windows10Upgrade" /reset >nul 2>&1
  196. del %SystemDrive%\Windows10Upgrade\*.* /f /q >nul 2>&1
  197. rmdir %SystemDrive%\Windows10Upgrade /s /q >nul 2>&1
  198. md "%systemdrive%\Windows10Upgrade" >nul 2>&1
  199. attrib +s +h %systemdrive%\Windows10Upgrade >nul 2>&1
  200. %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
  201. ::::::::::::::::::::::::::::
  202. ::Disable rempl
  203. if not exist "%ProgramFiles%\rempl" goto norempl
  204. takeown /f "%ProgramFiles%\rempl" /a >nul 2>&1
  205. icacls "%ProgramFiles%\rempl" /reset >nul 2>&1
  206. for %%? in ("%ProgramFiles%\rempl\*") do (
  207. takeown /f "%%?" /a >nul 2>&1
  208. icacls "%%?" /reset >nul 2>&1
  209. )
  210. del %ProgramFiles%\rempl\*.* /f /q >nul 2>&1
  211. rmdir %ProgramFiles%\rempl /s /q >nul 2>&1
  212. :norempl
  213. ::The rempl folder doesn't exist, so create it and lock it from system access.
  214. md "%ProgramFiles%\rempl" >nul 2>&1
  215. attrib +s +h "%ProgramFiles%\rempl" >nul 2>&1
  216. %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
  217. ::::::::::::::::::::::::::::
  218. :: Disable all Language Components Installer tasks
  219. takeown /f "%systemroot%\System32\Tasks\Microsoft\Windows\LanguageComponentsInstaller\*" /a >nul 2>&1
  220. icacls "%systemroot%\System32\Tasks\Microsoft\Windows\LanguageComponentsInstaller\*" /q /c /t /reset >nul 2>&1
  221. for %%? in ("%systemroot%\System32\Tasks\Microsoft\Windows\LanguageComponentsInstaller\*") do schtasks /change /tn "Microsoft\Windows\LanguageComponentsInstaller\%%~nx?" /disable >nul 2>&1
  222. ::::::::::::::::::::::::::::
  223. :: Disable and lock all Windows Update tasks.
  224. takeown /f "%systemroot%\System32\Tasks\Microsoft\Windows\WindowsUpdate\*" /a >nul 2>&1
  225. icacls "%systemroot%\System32\Tasks\Microsoft\Windows\WindowsUpdate\*" /q /c /t /reset >nul 2>&1
  226. for %%? in ("%systemroot%\System32\Tasks\Microsoft\Windows\WindowsUpdate\*") do schtasks /change /tn "Microsoft\Windows\WindowsUpdate\%%~nx?" /disable >nul 2>&1
  227. 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
  228. ::::::::::::::::::::::::::::
  229. ::Set list (s32list) of update hijacker files to be disabled, then disable everything in the list.
  230. set s32list=EOSNotify.exe WaaSMedic.exe WaasMedicSvc.dll WaaSMedicPS.dll WaaSAssessment.dll UsoClient.exe
  231. set s32list=%s32list% SIHClient.exe MusNotificationUx.exe MusNotification.exe osrss.dll
  232. set s32=%systemroot%\System32
  233. ::If "s32list" files were previously renamed by script, restore original file names
  234. for %%# in (%s32list%) do (
  235. ren "%s32%\%%#"-backup "%%#" >nul 2>&1
  236. if exist "%s32%\%%#" del "%s32%\%%#"-backup /f /q >nul 2>&1
  237. )
  238. ::Lock files
  239. for %%# in (%s32list%) do (
  240. takeown /f "%s32%\%%#" /a >nul 2>&1
  241. icacls "%s32%\%%#" /reset >nul 2>&1
  242. 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
  243. )
  244. ::If files in "s32list" aren't locked for whatever reason, rename them.
  245. for %%# in (%s32list%) do (
  246. ren "%s32%\%%#" "%%#"-backup >nul 2>&1
  247. if exist "%s32%\%%#"-backup del "%s32%\%%#" /f /q >nul 2>&1
  248. )
  249. ::::::::::::::::::::::::::::
  250. :: Create WDU.cmd
  251. (
  252. echo ::Allow only WDU task to run this file::
  253. echo whoami /user /nh ^| find /i "S-1-5-18" ^|^| exit
  254. echo cd /d "%%~dp0"
  255. echo ::Wait 5 minutes to prevent resource hogging after reboot with missed update::
  256. echo timeout /t 300^>nul
  257. echo ::If WUMT or WuMgr are running, cancel Defender update and exit. If not, continue::
  258. echo tasklist ^| findstr /i "wumt_x86.exe wumt_x64.exe wumgr.exe" ^&^& exit 1
  259. echo ::If Windows Defender is running, update it. If not, cancel Defender update and exit::
  260. echo sc query ^| find /i "windefend" ^|^| exit 1
  261. echo ::Enable Windows Update service and update Defender, then disable Update Service::
  262. echo wub.exe /e
  263. echo timeout /t 10
  264. echo "%%ProgramFiles%%\Windows Defender\MpCmdRun.exe" -SignatureUpdate
  265. echo wub.exe /d /p
  266. echo exit /b %%errorlevel%%
  267. )>.\bin\wdu.cmd"
  268. ::::::::::::::::::::::::::::
  269. ::Create WDU task, and wub_task
  270. call :create_task WDU "Windows Defender Update"
  271. call :create_task Wub_task "Windows Update Blocker Auto-Renewal"
  272. ::::::::::::::::::::::::::::
  273. ::Disable update service.
  274. call :wuauserv d
  275. ::::::::::::::::::::::::::::
  276. echo Windows 10 updates disabled.
  277. echo Close window ^(click "X"^) if done, or press a key to check for updates...
  278. pause >nul 2>&1
  279. :splash
  280. cls
  281. echo.
  282. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ::::::::::::::::::::::::::::::::
  283. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ : ^ Welcome to manual updates! ^ :
  284. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ::::::::::::::::::::::::::::::::
  285. echo.
  286. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ The Windows Update Service is now DISABLED and stopped.
  287. echo ^ ^ The tasks "WDU" (Windows Defender Update) and "wub_task" (Forces Update service off
  288. echo ^ ^ ^ ^ ^ ^ ^ ^ after reboot and login) have been (re)created.
  289. echo.
  290. echo ^ * ^ Update Hijackers are now disabled! (see readme for details)
  291. echo ^ * ^ If you just want to disable the Update Hijackers and not check for or install
  292. echo ^ ^ ^ ^ updates, you may close this screen now.
  293. echo.
  294. echo ^ * ^ If you choose to review any available Windows updates, the script enables and
  295. echo ^ ^ ^ ^ starts only the Windows Update Service, then runs the Windows update Manager
  296. echo ^ ^ ^ ^ (WuMgr) or the Windows Update MiniTool (WUMT) to find and then hide or install
  297. echo ^ ^ ^ ^ selected Windows updates. If you run WUMT, don't change WUMT settings while
  298. echo ^ ^ ^ ^ running this script. If WuMgr or WUMT is offering updates, you need to hide or
  299. echo ^ ^ ^ ^ install them before closing WuMgr or WUMT.
  300. echo.
  301. echo ^ * ^ After checking for updates, the script stops and disables the Windows Update service
  302. echo ^ ^ ^ ^ when WuMgr or WUMT is closed whether or not the service was previously enabled.
  303. echo.
  304. echo ^ * ^ If you choose to use the Store, you can enable update service in Configurator.
  305. echo ^ ^ ^ ^ After using the Store, then either 1) disable update service or 2) continue script to
  306. echo ^ ^ ^ ^ check for Windows updates with WuMgr or WUMT after which the update service will be
  307. echo ^ ^ ^ ^ disabled.
  308. echo.
  309. echo ^ * ^ If you move this script to another folder run it again so the tasks will work!
  310. echo.
  311. echo ^ * ^ The included uninstaller undoes script changes.
  312. echo.&echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ---^>^>^> Press any key to continue. ^<^<^<---
  313. pause > nul
  314. ::::::::::::::::::::::::::::
  315. ::Internet connection check
  316. cls
  317. echo Internet check.
  318. ping pool.ntp.org > nul
  319. cls
  320. if errorlevel 1 (echo.&echo Internet connection test failed. & echo ^(Tested with ping to pool.ntp.org. Please report if this IP is &echo unavailable in your area.^)&echo.&echo ---^>^>^> Press a key to continue if you're sure internet is working. ^<^<^<--- & echo.&echo It's safe to cancel now if needed. Your system will not be left in an unstable state.&echo ^(Ctrl-C, Alt-F4, or click "X" to cancel and exit^)) else (goto ContinePostInternetCheck)
  321. pause > nul
  322. :ContinePostInternetCheck
  323. ::::::::::::::::::::::::::::
  324. ::Windows Update Service Configurator
  325. cls
  326. echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.
  327. echo. & echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Initializing Configurator...
  328. ::disable windows update service except when wumt is run.
  329. :wudisable
  330. call :wuauserv d
  331. cls
  332. echo.&echo.&echo.
  333. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  334. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ : ^Windows 10 Update Control Wrapper Script Service Configurator ^:
  335. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  336. echo.&echo.&echo.
  337. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ---^>^>^> Windows Update Service is DISABLED and stopped ^(default^) ^<^<^<---
  338. echo.&echo.&echo. ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ [E]nable Update Service temporarily to use Windows Store.
  339. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ or
  340. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ [1] Continue script to run Windows Update Manager (WuMgr)
  341. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ and check for Windows Updates.
  342. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ or
  343. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ [2] Continue script to run Windows Update Minitool (WUMT)
  344. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ and check for Windows Updates.
  345. echo.&
  346. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ The Windows Update service will be automatically
  347. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ started and stopped.
  348. echo.&
  349. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ [Q]uit script, or "Alt + F4", or close window, if you're just
  350. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ verifying or are finished changing the update service setting.
  351. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ It stays how it's set above.
  352. echo.&echo.&echo.&echo.
  353. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Please select [E], [1], [2], or [Q] (or close window)
  354. echo.&echo.&echo.
  355. CHOICE /C E12Q /M "Your choice?:" >nul 2>&1
  356. if %errorlevel%==4 (exit)
  357. if %errorlevel%==3 (goto :StartWUMT)
  358. if %errorlevel%==2 (set "WuMgr=Y"&goto :StartWUMT)
  359. cls
  360. echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.
  361. echo.&echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Please wait while Windows Update Service is enabled...
  362. ::enable windows update service
  363. :wuenable
  364. call :wuauserv e
  365. echo.&echo.
  366. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  367. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ : ^Windows 10 Update Control Wrapper Script Service Configurator ^:
  368. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: &echo.&echo.
  369. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ---^>^>^> Windows Update Service is ENABLED ^(for Store^) ^<^<^<---
  370. echo.&echo.&echo. ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ [D]isable Update Service when finished using Store.
  371. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ or
  372. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ [1] Continue script to run Windows Update Manager (WuMgr)
  373. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ and check for Windows Updates.
  374. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ or
  375. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ [2] Continue script to run Windows Update Minitool (WUMT)
  376. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ and check for Windows Updates.
  377. echo.
  378. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ *Update service will be disabled automatically after
  379. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ update check and WUMT/WuMgr is closed.*
  380. echo.&echo.&echo.&echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Please select [D], [1], or [2]
  381. echo.&echo.&echo.&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 D12 /M "Your choice?:" >nul 2>&1
  386. if %errorlevel%==3 (goto :StartWUMT)
  387. if %errorlevel%==2 (set "WuMgr=Y"&goto :StartWUMT)
  388. if %errorlevel%==1 (
  389. cls
  390. echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.
  391. echo.&echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Please wait while Windows Update Service is disabled...
  392. goto wudisable
  393. )
  394. ::::::::::::::::::::::::::::
  395. :create_task
  396. set "w=echo f.writeline "
  397. echo Set Fso=CreateObject^("Scripting.FileSystemObject"^):Set f=Fso.CreateTextFile^(fso.GetParentFolderName^(WScript.ScriptFullName^) ^& "\task.xml",True,True^)>task.vbs
  398. if /i %1==wdu (
  399. rem Create automatic Windows Defender Update "WDU" task that updates Defender only if it's enabled and running.
  400. rem Create WDU.xml
  401. rem
  402. rem
  403. rem Creating Windows Defender Update auto renewal task
  404. rem
  405. (
  406. %w%"<?xml version=""1.0"" encoding=""UTF-16""?>"
  407. %w%"<Task version=""1.2"" xmlns=""http://schemas.microsoft.com/windows/2004/02/mit/task"">"
  408. %w%"<RegistrationInfo>"
  409. %w%"<Date>2016-02-18T08:29:39</Date>"
  410. %w%"<Author>pf100\rpo</Author>"
  411. %w%"<URI>WindowsDefenderUpdate</URI>"
  412. %w%"</RegistrationInfo>"
  413. %w%"<Triggers>"
  414. %w%"<CalendarTrigger>"
  415. %w%"<StartBoundary>2016-01-01T00:01:00</StartBoundary>"
  416. %w%"<Enabled>true</Enabled>"
  417. %w%"<ScheduleByDay>"
  418. %w%"<DaysInterval>1</DaysInterval>"
  419. %w%"</ScheduleByDay>"
  420. %w%"</CalendarTrigger>"
  421. %w%"<CalendarTrigger>"
  422. %w%"<StartBoundary>2016-01-01T06:01:00</StartBoundary>"
  423. %w%"<Enabled>true</Enabled>"
  424. %w%"<ScheduleByDay>"
  425. %w%"<DaysInterval>1</DaysInterval>"
  426. %w%"</ScheduleByDay>"
  427. %w%"</CalendarTrigger>"
  428. %w%"<CalendarTrigger>"
  429. %w%"<StartBoundary>2016-01-01T12:01:00</StartBoundary>"
  430. %w%"<Enabled>true</Enabled>"
  431. %w%"<ScheduleByDay>"
  432. %w%"<DaysInterval>1</DaysInterval>"
  433. %w%"</ScheduleByDay>"
  434. %w%"</CalendarTrigger>"
  435. %w%"<CalendarTrigger>"
  436. %w%"<StartBoundary>2016-01-01T18:01:00</StartBoundary>"
  437. %w%"<Enabled>true</Enabled>"
  438. %w%"<ScheduleByDay>"
  439. %w%"<DaysInterval>1</DaysInterval>"
  440. %w%"</ScheduleByDay>"
  441. %w%"</CalendarTrigger>"
  442. %w%"<BootTrigger>"
  443. %w%"<Enabled>true</Enabled>"
  444. %w%"<Delay>PT10M</Delay>"
  445. %w%"</BootTrigger>"
  446. %w%"<LogonTrigger>"
  447. %w%"<Enabled>true</Enabled>"
  448. %w%"</LogonTrigger>"
  449. %w%"</Triggers>"
  450. %w%"<Principals>"
  451. %w%"<Principal id=""Author"">"
  452. %w%"<UserId>S-1-5-18</UserId>"
  453. %w%"<RunLevel>HighestAvailable</RunLevel>"
  454. %w%"</Principal>"
  455. %w%"</Principals>"
  456. %w%"<Settings>"
  457. %w%"<MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>"
  458. %w%"<DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>"
  459. %w%"<StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>"
  460. %w%"<AllowHardTerminate>true</AllowHardTerminate>"
  461. %w%"<StartWhenAvailable>false</StartWhenAvailable>"
  462. %w%"<RunOnlyIfNetworkAvailable>true</RunOnlyIfNetworkAvailable>"
  463. %w%"<IdleSettings>"
  464. %w%"<StopOnIdleEnd>false</StopOnIdleEnd>"
  465. %w%"<RestartOnIdle>false</RestartOnIdle>"
  466. %w%"</IdleSettings>"
  467. %w%"<AllowStartOnDemand>true</AllowStartOnDemand>"
  468. %w%"<Enabled>true</Enabled>"
  469. %w%"<Hidden>false</Hidden>"
  470. %w%"<RunOnlyIfIdle>false</RunOnlyIfIdle>"
  471. %w%"<WakeToRun>false</WakeToRun>"
  472. %w%"<ExecutionTimeLimit>P3D</ExecutionTimeLimit>"
  473. %w%"<Priority>7</Priority>"
  474. %w%"</Settings>"
  475. %w%"<Actions Context=""Author"">"
  476. %w%"<Exec>"
  477. %w%"<Command>""" ^& FSO.GetParentFolderName^(Wscript.ScriptFullName^) ^& "\bin\WDU.cmd" ^& """</Command>"
  478. %w%"</Exec>"
  479. %w%"</Actions>"
  480. %w%"</Task>"
  481. )>>task.vbs
  482. )
  483. if /i %1==wub_task (
  484. rem
  485. rem Create Windows Update Blocker "Wub_task" that sets your desired Windows Update service state at boot.
  486. rem
  487. rem Create Wub_task
  488. rem
  489. rem
  490. (
  491. %w%"<?xml version=""1.0"" encoding=""UTF-16""?>"
  492. %w%"<Task version=""1.2"" xmlns=""http://schemas.microsoft.com/windows/2004/02/mit/task"">"
  493. %w%"<RegistrationInfo>"
  494. %w%"<Date>2016-02-18T08:29:39</Date>"
  495. %w%"<Author>pf100\rpo</Author>"
  496. %w%"<URI>\wub_task</URI>"
  497. %w%"</RegistrationInfo>"
  498. %w%"<Triggers>"
  499. %w%"<BootTrigger>"
  500. %w%"<Enabled>true</Enabled>"
  501. %w%"</BootTrigger>"
  502. %w%"<LogonTrigger>"
  503. %w%"<Enabled>true</Enabled>"
  504. %w%"</LogonTrigger>"
  505. %w%"</Triggers>"
  506. %w%"<Principals>"
  507. %w%"<Principal id=""Author"">"
  508. %w%"<RunLevel>HighestAvailable</RunLevel>"
  509. %w%"</Principal>"
  510. %w%"</Principals>"
  511. %w%"<Settings>"
  512. %w%"<MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>"
  513. %w%"<DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>"
  514. %w%"<StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>"
  515. %w%"<AllowHardTerminate>true</AllowHardTerminate>"
  516. %w%"<StartWhenAvailable>true</StartWhenAvailable>"
  517. %w%"<RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>"
  518. %w%"<IdleSettings>"
  519. %w%"<StopOnIdleEnd>false</StopOnIdleEnd>"
  520. %w%"<RestartOnIdle>false</RestartOnIdle>"
  521. %w%"</IdleSettings>"
  522. %w%"<AllowStartOnDemand>true</AllowStartOnDemand>"
  523. %w%"<Enabled>true</Enabled>"
  524. %w%"<Hidden>false</Hidden>"
  525. %w%"<RunOnlyIfIdle>false</RunOnlyIfIdle>"
  526. %w%"<WakeToRun>false</WakeToRun>"
  527. %w%"<ExecutionTimeLimit>PT72H</ExecutionTimeLimit>"
  528. %w%"<Priority>7</Priority>"
  529. %w%"</Settings>"
  530. %w%"<Actions Context=""Author"">"
  531. %w%"<Exec>"
  532. %w%"<Command>""" ^& FSO.GetParentFolderName^(Wscript.ScriptFullName^) ^& "\bin\Wub.exe""</Command>"
  533. %w%"<Arguments>/d /p</Arguments>"
  534. %w%"</Exec>"
  535. %w%"</Actions>"
  536. %w%"</Task>"
  537. )>>task.vbs
  538. )
  539. echo f.Close>>task.vbs & task.vbs
  540. ::
  541. schtasks /delete /tn "%1" /f >nul 2>&1
  542. schtasks /create /tn "\Microsoft\Sledgehammer\%1" /ru "SYSTEM" /xml task.xml /F >nul 2>&1 || (
  543. cls&echo.&echo Creating %2 %1 task errored.&echo.&echo.&echo Press any key to exit... & pause > nul &exit)
  544. del task.vbs task.xml >nul 2>&1
  545. exit /b
  546. ::::::::::::::::::::::::::::
  547. :wuauserv
  548. if /i "%1"=="e" (set "wub=wub.exe /e" & set "status=True") else (set "wub=wub.exe /d /p" & set "status=False")
  549. timeout -t 1 > nul
  550. .\bin\%wub%
  551. set /a "max_retry=10" & set /a "i=0"
  552. :wuauserv1
  553. if %i%==%max_retry% (echo Operation did not complete within %max_retry% s. Press any key do exit...&pause>nul&exit)
  554. set /a "i+=1"
  555. WMIC Service WHERE "Name = 'Wuauserv'" GET Started | find /i "%status%" >nul && exit /b || (timeout /t 1 >nul & goto :wuauserv1)
  556. ::::::::::::::::::::::::::::
  557. :StartWUMT
  558. cls
  559. (
  560. echo @echo off
  561. echo :loop
  562. echo net start wuauserv
  563. echo timeout /t 10
  564. echo goto loop
  565. )>WU-keep-alive.cmd
  566. (
  567. echo @echo off
  568. echo cd /d "%%~dp0"
  569. echo del WU-keep-alive.cmd
  570. echo .\bin\wub.exe /d /p
  571. echo del close.cmd ^& exit
  572. )>close.cmd
  573. if not defined WuMgr (
  574. set check_updates="%wumt%" -update "-onclose close.cmd"
  575. ) else (
  576. set check_updates=.\bin\wumgr.exe -update -online 7971f918-a847-4430-9279-4a52d1efe18d -provisioned -onclose close.cmd)
  577. call :wuauserv e
  578. echo CreateObject^("WScript.Shell"^).Run "WU-keep-alive.cmd",0 >WU-keep-alive.vbs&WU-keep-alive.vbs&del WU-keep-alive.vbs
  579. Start "" %check_updates%
  580. exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement