Advertisement
pf100

v2.5.7WumtWrapperScript.cmd

Feb 2nd, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.34 KB | None | 0 0
  1. @echo off
  2. mode con cols=89 lines=34
  3. Title WUMT Wrapper Script 2.5.7
  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. 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=NSudoCx64.exe"
  116. set "wumt=wumt_x64.exe"
  117. ) else (
  118. set "nsudovar=NSudoc.exe"
  119. set "wumt=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. If so, just close it.
  125. echo Press a key to acknowledge this and please wait for the uninstall to finish.
  126. echo Script will continue after uninstall and removal is completed...
  127. pause > nul
  128. echo Uninstalling Windows 10 Update Assistant...
  129. %systemdrive%\Windows10Upgrade\Windows10UpgraderApp.exe /forceuninstall
  130. timeout /t 10 /nobreak)
  131. del %SystemDrive%\Windows10Upgrade\*.* /f /q >nul 2>&1
  132. rmdir %SystemDrive%\Windows10Upgrade /s /q >nul 2>&1
  133. del %systemroot%\UpdateAssistant\*.* /f /q >nul 2>&1
  134. if not exist %systemroot%\UpdateAssistant md "%systemroot%\UpdateAssistant" >nul 2>&1
  135. %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
  136. del %systemroot%\UpdateAssistantV2\*.* /f /q >nul 2>&1
  137. if not exist %systemroot%\UpdateAssistantV2 md "%systemroot%\UpdateAssistantV2" >nul 2>&1
  138. %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
  139. if not exist %systemdrive%\Windows10Upgrade md "%systemdrive%\Windows10Upgrade" >nul 2>&1
  140. attrib +s +h “%systemdrive%\Windows10Upgrade” >nul 2>&1
  141. %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
  142. ::::::::::::::::::::::::::::
  143. echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.
  144. echo. & echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Initializing script...
  145. ::::::::::::::::::::::::::::
  146. if exist wub.exe-backup ren wub.exe-backup wub.exe
  147. ::::::::::::::::::::::::::::
  148. :: Disable all Language Components Installer tasks
  149. takeown /f "%systemroot%\System32\Tasks\Microsoft\Windows\LanguageComponentsInstaller\*" /a >nul 2>&1
  150. icacls "%systemroot%\System32\Tasks\Microsoft\Windows\LanguageComponentsInstaller\*" /q /c /t /reset >nul 2>&1
  151. for %%? in ("%systemroot%\System32\Tasks\Microsoft\Windows\LanguageComponentsInstaller\*") do schtasks /change /tn "Microsoft\Windows\LanguageComponentsInstaller\%%~nx?" /disable >nul 2>&1
  152. ::::::::::::::::::::::::::::
  153. :: Disable and lock all Windows Update tasks.
  154. takeown /f "%systemroot%\System32\Tasks\Microsoft\Windows\WindowsUpdate\*" /a >nul 2>&1
  155. icacls "%systemroot%\System32\Tasks\Microsoft\Windows\WindowsUpdate\*" /q /c /t /reset >nul 2>&1
  156. for %%? in ("%systemroot%\System32\Tasks\Microsoft\Windows\WindowsUpdate\*") do schtasks /change /tn "Microsoft\Windows\WindowsUpdate\%%~nx?" /disable >nul 2>&1
  157. 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
  158. ::::::::::::::::::::::::::::
  159. ::Set list (s32list) of update hijacker files to be disabled, then disable everything in the list.
  160. set s32list=EOSNotify.exe WaaSMedic.exe WaasMedicSvc.dll WaaSMedicPS.dll WaaSAssessment.dll UsoClient.exe
  161. set s32list=%s32list% SIHClient.exe MusNotificationUx.exe MusNotification.exe osrss.dll CompatTelRunner.exe
  162. set s32=%systemroot%\System32
  163. ::If "s32list" files were previously renamed by script, restore original file names
  164. for %%# in (%s32list%) do (
  165. ren "%s32%\%%#"-backup "%%#" >nul 2>&1
  166. if exist "%s32%\%%#" del "%s32%\%%#"-backup /f /q >nul 2>&1
  167. )
  168. timeout /t 2 >nul 2>&1
  169. ::Lock files
  170. for %%# in (%s32list%) do (
  171. takeown /f "%s32%\%%#" /a >nul 2>&1
  172. icacls "%s32%\%%#" /reset >nul 2>&1
  173. 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
  174. )
  175. timeout /t 2 >nul 2>&1
  176. ::If files in "s32list" aren't locked for whatever reason, rename them.
  177. for %%# in (%s32list%) do (
  178. ren "%s32%\%%#" "%%#"-backup >nul 2>&1
  179. if exist "%s32%\%%#"-backup del "%s32%\%%#" /f /q >nul 2>&1
  180. )
  181. ::::::::::::::::::::::::::::
  182. ::Disable files in rempl folder if folder exists, then lock rempl folder acess also.
  183. if not exist "%ProgramFiles%\rempl" goto norempl
  184. for %%? in ("%ProgramFiles%\rempl\*") do (
  185. takeown /f "%%?" /a >nul 2>&1
  186. icacls "%%?" /reset >nul 2>&1
  187. %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
  188. )
  189. %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
  190. ::::::::::::::::::::::::::::
  191. :norempl
  192. ::The rempl folder doesn't exist, so create it and lock it from system access.
  193. md "%ProgramFiles%\rempl" >nul 2>&1
  194. %nsudovar% -ShowWindowMode:Hide -Wait -U:T -P:E "%systemroot%\System32\icacls.exe" "%ProgramFiles%\rempl" /inheritance:r /remove:g *S-1-5-32-544 *S-1-5-11 *S-1-5-32-545 *S-1-5-18 >nul 2>&1
  195. ::::::::::::::::::::::::::::
  196. cls
  197. echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.
  198. echo. & echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Initializing script...
  199. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Creating Tasks...
  200. ::::::::::::::::::::::::::::
  201. :: Create WDU.cmd
  202. (
  203. echo SETLOCAL EnableDelayedExpansion
  204. echo ::Allow only WDU task to run this file::
  205. echo whoami /user /nh ^| find /i "S-1-5-18" ^|^| exit
  206. echo cd /d "%%~dp0"
  207. echo ::Wait 5 minutes to prevent resource hogging after reboot with missed update::
  208. echo timeout /t 300
  209. echo ::If WUMT or WuMgr are running, cancel Defender update and exit. If not, continue::
  210. echo tasklist ^| findstr /irc:"wumt_x.*exe"
  211. echo if %%errorlevel%% equ 0 goto skipdefenderupdate
  212. echo tasklist ^| findstr "wumgr.exe"
  213. echo if %%errorlevel%% equ 0 goto skipdefenderupdate
  214. echo ::If Windows Defender is running, update it. If not, cancel Defender update and exit::
  215. echo sc query ^| find /i "windefend"
  216. echo if %%errorlevel%% equ 1 goto skipdefenderupdate
  217. echo ::Enable Windows Update service and update Defender, then disable Update Service::
  218. echo if not exist wub.exe-backup ^(wub.exe /e^)
  219. echo timeout /t 10
  220. echo "%%ProgramFiles%%\Windows Defender\MpCmdRun.exe" -SignatureUpdate
  221. echo if not exist wub.exe-backup ^(wub.exe /d /p^)
  222. echo goto defenderupdated
  223. echo :skipdefenderupdate
  224. echo set errorlevel=1
  225. echo :defenderupdated
  226. echo exit /b %%errorlevel%%
  227. )>wdu.cmd"
  228. ::::::::::::::::::::::::::::
  229. ::Create WDU task, and wub_task
  230. call :createwdu
  231. call :createwub_task
  232. ::::::::::::::::::::::::::::
  233. cls
  234. echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.
  235. echo. & echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Initializing script...
  236. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Creating Tasks...
  237. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Disabling update service...
  238. ::::::::::::::::::::::::::::
  239. ::Disable update service.
  240. wub.exe /d /p >nul 2>&1
  241. timeout /t 2 >nul 2>&1
  242. ::::::::::::::::::::::::::::
  243. :splash
  244. cls
  245. echo.
  246. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ::::::::::::::::::::::::::::::::
  247. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ : ^ Welcome to manual updates! ^ :
  248. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ::::::::::::::::::::::::::::::::
  249. echo.
  250. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ The Windows Update Service is now DISABLED and stopped.
  251. echo ^ ^ The tasks "WDU" (Windows Defender Update) and "wub_task" (Forces Update service off
  252. echo ^ ^ ^ ^ ^ ^ ^ ^ after reboot and login) have been (re)created.
  253. echo.
  254. echo ^ * ^ Update Hijackers are now disabled! (see readme for details)
  255. echo ^ * ^ If you just want to disable the Update Hijackers and not check for or install
  256. echo ^ ^ ^ ^ updates, you may close this screen now.
  257. echo.
  258. echo ^ * ^ If you choose to review any available Windows updates, the script enables and
  259. echo ^ ^ ^ ^ starts only the Windows Update Service, then runs the Windows update Manager
  260. echo ^ ^ ^ ^ (WuMgr) or the Windows Update MiniTool (WUMT) to find and then hide or install
  261. echo ^ ^ ^ ^ selected Windows updates. If you run WUMT, don't change WUMT settings while
  262. echo ^ ^ ^ ^ running this script. If WuMgr or WUMT is offering updates, you need to hide or
  263. echo ^ ^ ^ ^ install them before closing WuMgr or WUMT.
  264. echo.
  265. echo ^ * ^ After checking for updates, the script stops and disables the Windows Update service
  266. echo ^ ^ ^ ^ when WuMgr or WUMT is closed regardless of whether the service was previously enabled
  267. echo.
  268. echo ^ * ^ If you choose to use the Store, you can enable update service in Configurator.
  269. echo ^ ^ ^ ^ After using the Store, then either 1) disable update service or 2) continue script to
  270. echo ^ ^ ^ ^ check for Windows updates with WUMT after which the update service will be disabled.
  271. echo.
  272. echo ^ * ^ If you move this script to another folder run it again so the tasks will work!
  273. echo.
  274. echo ^ * ^ The included uninstaller undoes script changes.
  275. echo.&echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ---^>^>^> Press any key to continue. ^<^<^<---
  276. pause > nul
  277. ::::::::::::::::::::::::::::
  278. ::Windows Update Service Configurator
  279. cls
  280. echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.
  281. echo. & echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Initializing Configurator...
  282. ::disable windows update service except when wumt is run.
  283. :wudisable
  284. wub.exe /d /p >nul 2>&1
  285. timeout /t 3 /nobreak >nul 2>&1
  286. cls
  287. echo.&echo.
  288. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  289. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ :^ WUMT Wrapper Script Windows Update Service Configurator^ :
  290. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: &echo.&echo.
  291. echo.&echo.&echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ---^>^>^> Windows Update Service is DISABLED and stopped ^(default^) ^<^<^<---
  292. echo.&echo.&echo.&echo.&echo [E]nable Update Service temporarily to use Windows Store.
  293. echo.& echo [C]ontinue script to run WUMT and check for Windows Updates.
  294. echo ^ ^ ^ The Windows Update service will be automatically started and stopped.
  295. echo.& echo [Q]uit script, or "Alt + F4", or close window, if you're just verifying or are
  296. echo ^ ^ ^ finished changing the update service setting. It stays how it's set above.
  297. echo.&echo.&echo.&echo.&echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Please select [E], [C], or [Q] (or close window)
  298. echo.&echo.&echo.&echo.&echo.&echo.&echo.
  299. CHOICE /C ECQ /M "Your choice?:" >nul 2>&1
  300. if %errorlevel%==3 (exit)
  301. if %errorlevel%==2 (goto StartWUMT)
  302. cls
  303. echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.
  304. echo.&echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Please wait while Windows Update Service is enabled...
  305. ::enable windows update service
  306. :wuenable
  307. wub.exe /e >nul 2>&1
  308. timeout /t 2 /nobreak >nul 2>&1
  309. cls
  310. echo.&echo.&echo.
  311. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  312. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ :^ WUMT Wrapper Script Windows Update Service Configurator^ :
  313. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: &echo.&echo.&echo.
  314. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ---^>^>^> Windows Update Service is ENABLED ^(for Store^) ^<^<^<---
  315. echo.&echo.&echo.&echo [D]isable Update Service and only allow to run during script updates (default).
  316. echo.&echo [C]ontinue script to run WUMT and check for Windows Updates. Update service will
  317. echo ^ ^ ^ ^ ^ ^ be disabled automatically after update check and WUMT is closed.
  318. echo.&echo.&echo.&echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Please select [D] or [C]
  319. echo.&echo.&echo.&echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  320. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ :^ Don't close this window or update service will stay on!!!^ :
  321. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ : ^ ^ Don't worry. Just run the script again to turn it off ^ ^ :
  322. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  323. echo.&echo.&echo.&echo.
  324. CHOICE /C DC /M "Your choice?:" >nul 2>&1
  325. if %errorlevel%==2 (goto StartWUMT)
  326. if %errorlevel%==1 (
  327. cls
  328. echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.
  329. echo.&echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Please wait while Windows Update Service is disabled...
  330. goto wudisable
  331. )
  332. ::::::::::::::::::::::::::::
  333. :createwdu
  334. :: Create automatic Windows Defender Update "WDU" task that updates Defender only if it's enabled and running.
  335. set "Task_Name=WDU"
  336. :: Create WDU.xml
  337. ::
  338. set "w=echo f.writeline "
  339. (
  340. echo Set Fso=CreateObject^("Scripting.FileSystemObject"^):Set f=Fso.CreateTextFile^(fso.GetSpecialFolder^(2^) ^& "\task.xml",True^)
  341. %w%"<?xml version=""1.0"" encoding=""UTF-16""?>"
  342. %w%"<Task version=""1.2"" xmlns=""http://schemas.microsoft.com/windows/2004/02/mit/task"">"
  343. %w%"<RegistrationInfo>"
  344. %w%"<Date>2016-02-18T08:29:39</Date>"
  345. %w%"<Author>pf100\rpo</Author>"
  346. %w%"<URI>\WDU</URI>"
  347. %w%"</RegistrationInfo>"
  348. %w%"<Triggers>"
  349. %w%"<CalendarTrigger>"
  350. %w%"<Repetition>"
  351. %w%"<Interval>PT6H</Interval>"
  352. %w%"<StopAtDurationEnd>false</StopAtDurationEnd>"
  353. %w%"</Repetition>"
  354. %w%"<StartBoundary>2016-05-12T00:01:00.0</StartBoundary>"
  355. %w%"<Enabled>true</Enabled>"
  356. %w%"<ScheduleByDay>"
  357. %w%"<DaysInterval>1</DaysInterval>"
  358. %w%"</ScheduleByDay>"
  359. %w%"</CalendarTrigger>"
  360. %w%"</Triggers>"
  361. %w%"<Principals>"
  362. %w%"<Principal id=""Author"">"
  363. %w%"<RunLevel>HighestAvailable</RunLevel>"
  364. %w%"</Principal>"
  365. %w%"</Principals>"
  366. %w%"<Settings>"
  367. %w%"<MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>"
  368. %w%"<DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>"
  369. %w%"<StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>"
  370. %w%"<AllowHardTerminate>true</AllowHardTerminate>"
  371. %w%"<StartWhenAvailable>true</StartWhenAvailable>"
  372. %w%"<RunOnlyIfNetworkAvailable>true</RunOnlyIfNetworkAvailable>"
  373. %w%"<IdleSettings>"
  374. %w%"<StopOnIdleEnd>false</StopOnIdleEnd>"
  375. %w%"<RestartOnIdle>false</RestartOnIdle>"
  376. %w%"</IdleSettings>"
  377. %w%"<AllowStartOnDemand>true</AllowStartOnDemand>"
  378. %w%"<Enabled>true</Enabled>"
  379. %w%"<Hidden>false</Hidden>"
  380. %w%"<RunOnlyIfIdle>false</RunOnlyIfIdle>"
  381. %w%"<WakeToRun>false</WakeToRun>"
  382. %w%"<ExecutionTimeLimit>PT72H</ExecutionTimeLimit>"
  383. %w%"<Priority>7</Priority>"
  384. %w%"</Settings>"
  385. %w%"<Actions Context=""Author"">"
  386. %w%"<Exec>"
  387. %w%"<Command>""" ^& FSO.GetParentFolderName^(Wscript.ScriptFullName^) ^& "\%Task_Name%.cmd" ^& """</Command>"
  388. %w%"</Exec>"
  389. %w%"</Actions>"
  390. %w%"</Task>"
  391. echo f.Close
  392. )>"%~dp0task.vbs" &"%~dp0task.vbs" & del "%~dp0task.vbs"
  393. ::
  394. :: Creating Windows Defender Update auto renewal task
  395. ::
  396. schtasks /delete /tn "%Task_Name%" /f >nul 2>&1
  397. timeout /t 2 >nul 2>&1
  398. schtasks /query /tn "%Task_Name%" >nul 2>&1 || (
  399. schtasks /create /tn "%Task_Name%" /ru "SYSTEM" /xml "%temp%\task.xml" >nul 2>&1) || (
  400. cls&echo.&echo Creating Windows Defender Update Auto-Renewal %Task_Name% task errored.&echo.&echo %~dp0 is invalid path name.&echo.&echo English and other Western European language characters allowed only.&echo.&echo Move wrapper script folder to suitable path and run again.&echo.&echo See https://msdn.microsoft.com/en-us/library/cc195054.aspx for more information.&echo.&echo Press any key to exit... & pause > nul &exit)
  401. del "%temp%\task.xml" >nul 2>&1)
  402. exit /b
  403. ::::::::::::::::::::::::::::
  404. :createwub_task
  405. ::
  406. :: Create Windows Update Blocker "Wub_task" that sets your desired Windows Update service state at boot.
  407. ::
  408. :: Create Wub_task
  409. ::
  410. set "Task_Name=Wub_task"
  411. set "w=echo f.writeline "
  412. (
  413. echo Set Fso=CreateObject^("Scripting.FileSystemObject"^):Set f=Fso.CreateTextFile^(fso.GetSpecialFolder^(2^) ^& "\task.xml",True^)
  414. %w%"<?xml version=""1.0"" encoding=""UTF-16""?>"
  415. %w%"<Task version=""1.2"" xmlns=""http://schemas.microsoft.com/windows/2004/02/mit/task"">"
  416. %w%"<RegistrationInfo>"
  417. %w%"<Date>2016-02-18T08:29:39</Date>"
  418. %w%"<Author>pf100\rpo</Author>"
  419. %w%"<URI>\wub_task</URI>"
  420. %w%"</RegistrationInfo>"
  421. %w%"<Triggers>"
  422. %w%"<BootTrigger>"
  423. %w%"<StartBoundary>2016-02-18T08:29:00</StartBoundary>"
  424. %w%"<Enabled>true</Enabled>"
  425. %w%"</BootTrigger>"
  426. %w%"<LogonTrigger>"
  427. %w%"<Enabled>true</Enabled>"
  428. %w%"</LogonTrigger>"
  429. %w%"</Triggers>"
  430. %w%"<Principals>"
  431. %w%"<Principal id=""Author"">"
  432. %w%"<RunLevel>HighestAvailable</RunLevel>"
  433. %w%"</Principal>"
  434. %w%"</Principals>"
  435. %w%"<Settings>"
  436. %w%"<MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>"
  437. %w%"<DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>"
  438. %w%"<StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>"
  439. %w%"<AllowHardTerminate>true</AllowHardTerminate>"
  440. %w%"<StartWhenAvailable>true</StartWhenAvailable>"
  441. %w%"<RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>"
  442. %w%"<IdleSettings>"
  443. %w%"<StopOnIdleEnd>false</StopOnIdleEnd>"
  444. %w%"<RestartOnIdle>false</RestartOnIdle>"
  445. %w%"</IdleSettings>"
  446. %w%"<AllowStartOnDemand>true</AllowStartOnDemand>"
  447. %w%"<Enabled>true</Enabled>"
  448. %w%"<Hidden>false</Hidden>"
  449. %w%"<RunOnlyIfIdle>false</RunOnlyIfIdle>"
  450. %w%"<WakeToRun>false</WakeToRun>"
  451. %w%"<ExecutionTimeLimit>PT72H</ExecutionTimeLimit>"
  452. %w%"<Priority>7</Priority>"
  453. %w%"</Settings>"
  454. %w%"<Actions Context=""Author"">"
  455. %w%"<Exec>"
  456. %w%"<Command>""" ^& FSO.GetParentFolderName^(Wscript.ScriptFullName^) ^& "\Wub.exe""</Command>"
  457. %w%"<Arguments>/d /p</Arguments>"
  458. %w%"</Exec>"
  459. %w%"</Actions>"
  460. %w%"</Task>"
  461. echo f.Close
  462. )>"%~dp0task.vbs" & "%~dp0task.vbs" & del "%~dp0task.vbs"
  463. ::
  464. :: Creating Windows Update Blocker auto renewal task
  465. ::
  466. schtasks /delete /tn "%Task_Name%" /f >nul 2>&1
  467. timeout /t 2 >nul 2>&1
  468. schtasks /query /tn "%Task_Name%" >nul 2>&1 || (
  469. schtasks /create /tn "%Task_Name%" /ru "SYSTEM" /xml "%temp%\task.xml" >nul 2>&1) || (
  470. cls&echo.&echo Creating Windows Update Blocker Auto-Renewal %Task_Name% task errored.&echo.&echo %~dp0 is invalid path name.&echo.&echo English and other Western European language characters allowed only.&echo.&echo Move wrapper script folder to suitable path and run again.&echo.&echo See https://msdn.microsoft.com/en-us/library/cc195054.aspx for more information.&echo.&echo Press any key to exit... & pause > nul &exit)
  471. del "%temp%\task.xml" >nul 2>&1)
  472. exit /b
  473. ::::::::::::::::::::::::::::
  474. :StartWUMT
  475. cls
  476. (
  477. echo @echo off
  478. echo :loop
  479. echo net start wuauserv
  480. echo timeout /t 10
  481. echo goto loop
  482. )>WU-keep-alive.cmd
  483. (
  484. echo @echo off
  485. echo cd /d "%%~dp0"
  486. echo del WU-keep-alive.cmd
  487. echo wub.exe /d /p
  488. echo del close.cmd ^& exit
  489. )>close.cmd
  490. echo. & echo. & echo. & echo. & echo. & echo. & echo. & echo. & echo. & echo. & echo. & echo.
  491. echo ^ ^ ^ ^ ^ ^ ^ ^ To perform updates do you want to use Windows Update Manager (WuMgr)
  492. echo ^ ^ ^ ^ ^ ^ ^ ^ or Windows Update Minitool (WUMT)?
  493. echo. & echo ^ ^ ^ ^ ^ ^ ^ ^ For WuMgr press (1). for WUMT press (2).
  494. CHOICE /C 12 /M "Your choice?:" >nul 2>&1
  495. if %errorlevel%==2 (goto startwumt)
  496. wub.exe /e >nul 2>&1
  497. timeout /t 2 >nul 2>&1
  498. echo CreateObject^("WScript.Shell"^).Run "WU-keep-alive.cmd",0 >WU-keep-alive.vbs&WU-keep-alive.vbs&del WU-keep-alive.vbs
  499. Start "" wumgr.exe -update -online 7971f918-a847-4430-9279-4a52d1efe18d -provisioned -onclose close.cmd
  500. exit
  501. :startwumt
  502. wub.exe /e >nul 2>&1
  503. timeout /t 2 >nul 2>&1
  504. echo CreateObject^("WScript.Shell"^).Run "WU-keep-alive.cmd",0 >WU-keep-alive.vbs&WU-keep-alive.vbs&del WU-keep-alive.vbs
  505. Start "" "%wumt%" -update "-onclose close.cmd"
  506. exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement