pf100

v2.6.0v5WuWrapperScript.cmd

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