pf100

v2.6.0v9Win10Update_WrapperScript.cmd

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