Advertisement
pf100

v2.5.3NoVbWUMTWrapperScript.cmd

Sep 17th, 2018
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.03 KB | None | 0 0
  1. @echo off
  2. mode con cols=82 lines=30
  3. Title WUMT Wrapper Script 2.5.3
  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. *******************************************************************
  26. How it works: The script first checks if the OS is Windows 8.1 or older and if so
  27. it notifies the user, then exits. Windows 10 only!
  28. This script creates a smart Windows Defender Update task "WDU" that updates Windows
  29. Defender every 2 hours if it's running and enabled, and doesn't update it if it's not
  30. running and disabled, saving resources; auto-elevates, uninstalls and removes the
  31. Windows 10 Update Assistant, disables everything in the %programfiles%\rempl folder, resets and
  32. removes permissions from and disables these Update Hijackers:
  33. remsh.exe
  34. osrss.dll
  35. UsoClient.exe
  36. WaaSMedic.exe
  37. WaasMedicSvc.dll
  38. WaaSMedicPS.dll
  39. WaaSAssessment.dll
  40. MusNotification.exe
  41. MusNotificationUx.exe
  42. SIHClient.exe
  43. disables all WindowsUpdate tasks except for "Automatic App Update" task which can only run
  44. if the windows update service is enabled with the Configurator.
  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. :::::::::::::::::::::::::::::::::::::::::
  66. :: Automatically check & get admin rights
  67. :::::::::::::::::::::::::::::::::::::::::
  68. :: ECHO.
  69. :: ECHO =============================
  70. :: ECHO Running Admin shell
  71. :: ECHO =============================
  72. :: Check Privileges
  73. :: Get Privileges
  74. :: and
  75. :: Invoke UAC for Privilege Escalation
  76. :: Notify if error escalating
  77. :: and prevent looping if escalation fails
  78. ::::::::::::::::::::::::::::
  79. set "params=Problem_with_elevating_UAC_for_Administrator_Privileges"&if exist "%temp%\getadmin.vbs" del "%temp%\getadmin.vbs"
  80. fsutil dirty query %systemdrive% >nul 2>&1 && goto :GotPrivileges
  81. :: The following test is to avoid infinite looping if elevating UAC for Administrator Privileges failed
  82. 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)
  83. cmd /u /c echo Set UAC = CreateObject^("Shell.Application"^) : UAC.ShellExecute "%~0", "%params%", "", "runas", 1 > "%temp%\getadmin.vbs"&cscript //nologo "%temp%\getadmin.vbs"&exit
  84. :GotPrivileges
  85. ::::::::::::::::::::::::::::
  86. ::Uninstall and remove Windows 10 Update assistant.
  87. ::Disable Windows Update Service until script menu screen.
  88. ::Reset (in case of wrong Permissions), remove Permissions from and
  89. ::disable "Update Hijackers"
  90. ::Install wub_task (prevents Windows Update service from starting after installing updates and rebooting).
  91. ::Install "WDU" task that only updates Defender if it's enabled. Otherwise it doesn't do anything.
  92. ::Enable and start the Windows Update Service (wuauserv).
  93. ::Run the correct version of WUMT for your architecture.
  94. ::Start WUMT in "auto-check for updates" mode.
  95. ::After updates are completed and WUMT is closed and/or the "reboot"
  96. ::button in WUMT is pressed, silently run wub.exe and disable and stop wuauserv
  97. ::::::::::::::::::::::::::::
  98. @echo off
  99. cls
  100. ::Test for Windows versions below Windows 10 and if so inform user, then exit...
  101. ::Get Windows OS build number
  102. for /f "tokens=2 delims==" %%a in ('wmic path Win32_OperatingSystem get BuildNumber /value') do (
  103. set /a WinBuild=%%a
  104. )
  105. if %winbuild% LEQ 9600 (
  106. cls
  107. echo.&echo This is not Windows 10. Press a key to exit...
  108. pause > nul
  109. exit
  110. )
  111. ::Remove Update Assistant
  112. if exist "%systemdrive%\Windows10Upgrade\Windows10UpgraderApp.exe" ( echo Windows 10 Update Assistant detected. Preparing to uninstall.
  113. echo The "Windows 10 Update Assistant has stopped working" dialog box may pop up. If so, just close it.
  114. echo Press a key to acknowledge this and please wait for the uninstall to finish.
  115. echo Script will continue after uninstall and removal is completed...
  116. pause > nul
  117. echo Uninstalling Windows 10 Update Assistant...
  118. %systemdrive%\Windows10Upgrade\Windows10UpgraderApp.exe /forceuninstall
  119. timeout /t 10 /nobreak)
  120. del %SystemDrive%\Windows10Upgrade\*.* /f /q >nul 2>&1
  121. rmdir %SystemDrive%\Windows10Upgrade /s /q >nul 2>&1
  122. del %systemroot%\UpdateAssistant\*.* /f /q >nul 2>&1
  123. rmdir %systemroot%\UpdateAssistant /s /q >nul 2>&1
  124. del %systemroot%\UpdateAssistantV2\*.* /f /q >nul 2>&1
  125. rmdir %systemroot%\UpdateAssistantV2 /s /q >nul 2>&1
  126. ::::::::::::::::::::::::::::
  127. echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.
  128. echo. & echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Initializing script...
  129. ::::::::::::::::::::::::::::
  130. ::In case new script is copied over old script while wub.exe-backup exists, then wub.exe would exist too,
  131. ::so check if windows update service is disabled or not and then correctly delete either wub.exe or wub.exe-backup.
  132. Reg query "HKLM\SYSTEM\CurrentControlSet\Services\wuauserv" /v "Start" | find "4" >nul 2>&1
  133. IF %ERRORLEVEL% == 0 (if exist "%~dp0wub.exe" del "%~dp0wub.exe-backup" /f /q >nul 2>&1) else (if exist "%~dp0wub.exe-backup" del "%~dp0wub.exe" /f /q >nul 2>&1)
  134. ::::::::::::::::::::::::::::
  135. :: Disable and lock all Windows Update tasks except for "Automatic App Update" and prevent them from being enabled.
  136. takeown /f "%systemroot%\System32\Tasks\Microsoft\Windows\WindowsUpdate\*" /a >nul 2>&1
  137. icacls "%systemroot%\System32\Tasks\Microsoft\Windows\WindowsUpdate\*" /q /c /t /reset >nul 2>&1
  138. for %%? in ("%systemroot%\System32\Tasks\Microsoft\Windows\WindowsUpdate\*") do schtasks /change /tn "Microsoft\Windows\WindowsUpdate\%%~nx?" /disable >nul 2>&1
  139. schtasks /change /tn "\Microsoft\Windows\WindowsUpdate\Automatic App Update" /enable >nul 2>&1
  140. 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
  141. icacls "%systemroot%\System32\Tasks\Microsoft\Windows\WindowsUpdate\Automatic App Update" /reset >nul 2>&1
  142. icacls "%systemroot%\System32\Tasks\Microsoft\Windows\WindowsUpdate\Automatic App Update" /setowner *S-1-5-18 >nul 2>&1
  143. ::::::::::::::::::::::::::::
  144. ::Set list (s32list) of update hijacker files to be disabled, then disable everything in the list.
  145. set s32list=EOSNotify.exe WaaSMedic.exe WaasMedicSvc.dll WaaSMedicPS.dll WaaSAssessment.dll UsoClient.exe
  146. set s32list=%s32list% SIHClient.exe MusNotificationUx.exe MusNotification.exe osrss.dll
  147. set s32=%systemroot%\System32
  148. for %%# in (%s32list%) do (
  149. takeown /f "%s32%\%%#" /a >nul 2>&1
  150. icacls "%s32%\%%#" /reset >nul 2>&1
  151. icacls "%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
  152. )
  153. ::::::::::::::::::::::::::::
  154. ::Disable update service.
  155. ren "%~dp0wub.exe-backup" wub.exe >nul 2>&1
  156. "%~dp0wub.exe" /d /p >nul 2>&1
  157. ::::::::::::::::::::::::::::
  158. ::Disable rempl
  159. for %%? in ("%ProgramFiles%\rempl\*") do (
  160. takeown /f "%%?" /a >nul 2>&1
  161. icacls "%%?" /reset >nul 2>&1
  162. icacls "%%?" /inheritance:r /remove *S-1-5-32-544 *S-1-5-11 *S-1-5-32-545 *S-1-5-18 >nul 2>&1
  163. )
  164. ::::::::::::::::::::::::::::
  165. :splash
  166. cls
  167. echo **********************************************************************************
  168. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Welcome to manual updates!
  169. echo.&echo ^ ^ ^ ^ ^ ^ ^ Automatic updates and "update hijackers" are now disabled.
  170. echo ^ ^ ^ ^ ^ ^ ^ Run script again after you install updates at least until
  171. echo ^ ^ ^ ^ ^ ^ ^ this screen appears to kill any newly installed update hijackers!
  172. echo ^ ^ ^ ^ ^ ^ ^ You may close this screen now with "Alt-F4" or click "X" in window.
  173. echo.
  174. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Press any key to continue to Configurator.
  175. echo.&echo **********************************************************************************
  176. echo Automatic updates and "update hijackers" are now turned off. This script automates
  177. echo the update process. It automatically disables a range of "Update Hijackers" such
  178. echo as: osrss, rempl, Uso, WaaS, SIH, and Update Assistant; enables and starts only
  179. echo the Windows Update Service, then runs the Windows Update MiniTool (WUMT). After
  180. echo updates, stops and disables the Windows Update service. The included uninstaller
  181. echo undoes script changes. Closing WUMT at any time disables updates again; however,
  182. echo if WUMT is already offering updates, you need to hide them and/or install them
  183. echo before closing WUMT or it may install them without asking next time. Don't change
  184. echo WUMT settings while running this script. If an update requires a reboot, re-run
  185. echo the script after the reboot and just close this screen to make sure the "Update
  186. echo Hijackers" stay off. Enable update service in Configurator in script to use the
  187. echo Store. Script will automatically disable Windows Update after update check and
  188. echo WUMT is closed. So enable updates, use store, then either 1) disable updates or
  189. echo 2) continue script to check for updates and update service will be disabled.
  190. echo If you move this script to another folder run it again so the tasks will work!
  191. echo **********************************************************************************
  192. echo.&echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Press any key to continue to Configurator.
  193. pause > nul
  194. ::::::::::::::::::::::::::::
  195. ::Windows Update Service Configurator
  196. cls
  197. echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.
  198. echo. & echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Initializing Configurator...
  199. ::disable windows update service except when wumt is run.
  200. :wudisable
  201. ren "%~dp0wub.exe-backup" wub.exe >nul 2>&1
  202. timeout /t 2 /nobreak >nul 2>&1
  203. "%~dp0wub.exe" /d /p >nul 2>&1
  204. timeout /t 2 /nobreak >nul 2>&1
  205. cls
  206. echo.&echo.&echo.
  207. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  208. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ :WUMT Wrapper Script Windows Update Service Configurator:
  209. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::: &echo.&echo.
  210. echo ^ ^ ^ ^ ^ ^ ---^>^>^> Windows Update Service is DISABLED and stopped ^(default^) ^<^<^<---
  211. echo.&echo.&echo [E]nable Update Service temporarily to use Windows Store.
  212. echo. & echo [C]ontinue script to run WUMT and check for Windows Updates.
  213. echo. & echo [Q]uit script, or "Alt + F4", or close window, if you're just verifying or are
  214. echo ^ ^ ^ finished changing the update service setting. It stays how it's set above.
  215. echo.&echo.&echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Please select [E], [C], or [Q] (or close window)
  216. CHOICE /C ECQ /M "Your choice?:" >nul 2>&1
  217. if %errorlevel%==3 (exit)
  218. if %errorlevel%==2 (goto StartWUMT)
  219. cls
  220. echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.
  221. echo.&echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Please wait while Windows Update Service is enabled.
  222. echo.&echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ This will take a few seconds...
  223. timeout /t 2 /nobreak >nul 2>&1
  224. ::enable windows update service
  225. :wuenable
  226. ren "%~dp0wub.exe-backup" wub.exe >nul 2>&1
  227. timeout /t 2 /nobreak >nul 2>&1
  228. "%~dp0wub.exe" /e >nul 2>&1
  229. timeout /t 2 /nobreak >nul 2>&1
  230. "%~dp0wub.exe" /e >nul 2>&1
  231. timeout /t 2 /nobreak >nul 2>&1
  232. ren "%~dp0wub.exe" wub.exe-backup >nul 2>&1
  233. timeout /t 2 /nobreak >nul 2>&1
  234. cls
  235. echo.&echo.&echo.
  236. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  237. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ :WUMT Wrapper Script Windows Update Service Configurator:
  238. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::: &echo.&echo.
  239. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ---^>^>^> Windows Update Service is ENABLED ^(for Store^) ^<^<^<---
  240. echo.&echo.&echo [D]isable Update Service and only allow to run during script updates (default).
  241. echo.&echo [C]ontinue script to run WUMT and check for Windows Updates. Update service will
  242. echo ^ ^ ^ ^ ^ ^ be disabled automatically after update check and WUMT is closed.
  243. echo.&echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Please select [D] or [C]
  244. echo.&echo.&echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  245. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ :Don't close this window or update service will stay on!!! :
  246. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ : ^ Don't worry. Just run the script again to turn it off. ^ :
  247. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  248. CHOICE /C DC /M "Your choice?:" >nul 2>&1
  249. if %errorlevel%==2 (goto StartWUMT)
  250. if %errorlevel%==1 (
  251. cls
  252. echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.
  253. echo. & echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Please wait while Windows Update Service is disabled.
  254. echo. & echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ This will take a few seconds...
  255. timeout /t 2 /nobreak >nul 2>&1
  256. goto wudisable
  257. )
  258. ::::::::::::::::::::::::::::
  259. :StartWUMT
  260. ::::::::::::::::::::::::::::
  261. ::
  262. :: Create automatic Windows Defender Update "WDU" task that updates Defender only if it's enabled and running.
  263. set "Task_Name=WDU"
  264. ::
  265. :: Create WDU.cmd
  266. ::
  267. (
  268. echo SETLOCAL EnableDelayedExpansion
  269. echo ::Allow only WDU task to run this file::
  270. echo whoami /user /nh ^| find /i "S-1-5-18" ^|^| exit
  271. echo cd /d "%%~dp0"
  272. echo ::Wait 5 minutes to prevent resource hogging after reboot with missed update::
  273. echo timeout /t 300
  274. echo ::If WUMT or WuMgr are running, cancel Defender update and exit. If not, continue::
  275. echo tasklist ^| findstr /irc:"wumt_x.*exe"
  276. echo if %%errorlevel%% equ 0 goto skipdefenderupdate
  277. echo tasklist ^| findstr "wumgr.exe"
  278. echo if %%errorlevel%% equ 0 goto skipdefenderupdate
  279. echo ::If Windows Defender is running, update it. If not, cancel Defender update and exit::
  280. echo sc query ^| find /i "windefend"
  281. echo if %%errorlevel%% equ 1 goto skipdefenderupdate
  282. echo ::Enable Windows Update service and update Defender, then disable Update Service::
  283. echo if not exist wub.exe-backup ^(wub.exe /e^)
  284. echo timeout /t 10
  285. echo "%%ProgramFiles%%\Windows Defender\MpCmdRun.exe" -SignatureUpdate
  286. echo if not exist wub.exe-backup ^(wub.exe /d /p^)
  287. echo goto defenderupdated
  288. echo :skipdefenderupdate
  289. echo set errorlevel=1
  290. echo :defenderupdated
  291. echo exit /b %%errorlevel%%
  292. )>"%~dp0wdu.cmd"
  293. ::
  294. :: Create WDU.xml
  295. ::
  296. (
  297. echo ^<?xml version="1.0" encoding="UTF-16"?^>
  298. echo ^<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task"^>
  299. echo ^<RegistrationInfo^>
  300. echo ^<Date^>2016-02-18T08:29:39^</Date^>
  301. echo ^<Author^>pf100\rpo^</Author^>
  302. echo ^<URI^>WindowsDefenderUpdate^</URI^>
  303. echo ^</RegistrationInfo^>
  304. echo ^<Triggers^>
  305. echo ^<CalendarTrigger^>
  306. echo ^<Repetition^>
  307. echo ^<Interval^>PT6H^</Interval^>
  308. echo ^<StopAtDurationEnd^>false^</StopAtDurationEnd^>
  309. echo ^</Repetition^>
  310. echo ^<StartBoundary^>2016-05-12T00:01:00.0^</StartBoundary^>
  311. echo ^<Enabled^>true^</Enabled^>
  312. echo ^<ScheduleByDay^>
  313. echo ^<DaysInterval^>1^</DaysInterval^>
  314. echo ^</ScheduleByDay^>
  315. echo ^</CalendarTrigger^>
  316. echo ^</Triggers^>
  317. echo ^<Principals^>
  318. echo ^<Principal id="Author"^>
  319. echo ^<UserId^>S-1-5-18^</UserId^>
  320. echo ^<RunLevel^>HighestAvailable^</RunLevel^>
  321. echo ^</Principal^>
  322. echo ^</Principals^>
  323. echo ^<Settings^>
  324. echo ^<MultipleInstancesPolicy^>IgnoreNew^</MultipleInstancesPolicy^>
  325. echo ^<DisallowStartIfOnBatteries^>false^</DisallowStartIfOnBatteries^>
  326. echo ^<StopIfGoingOnBatteries^>false^</StopIfGoingOnBatteries^>
  327. echo ^<AllowHardTerminate^>true^</AllowHardTerminate^>
  328. echo ^<StartWhenAvailable^>true^</StartWhenAvailable^>
  329. echo ^<RunOnlyIfNetworkAvailable^>true^</RunOnlyIfNetworkAvailable^>
  330. echo ^<IdleSettings^>
  331. echo ^<StopOnIdleEnd^>false^</StopOnIdleEnd^>
  332. echo ^<RestartOnIdle^>false^</RestartOnIdle^>
  333. echo ^</IdleSettings^>
  334. echo ^<AllowStartOnDemand^>true^</AllowStartOnDemand^>
  335. echo ^<Enabled^>true^</Enabled^>
  336. echo ^<Hidden^>false^</Hidden^>
  337. echo ^<RunOnlyIfIdle^>false^</RunOnlyIfIdle^>
  338. echo ^<WakeToRun^>false^</WakeToRun^>
  339. echo ^<ExecutionTimeLimit^>PT72H^</ExecutionTimeLimit^>
  340. echo ^<Priority^>7^</Priority^>
  341. echo ^</Settings^>
  342. echo ^<Actions Context="Author"^>
  343. echo ^<Exec^>
  344. echo ^<Command^>"%~dps0WDU.cmd"^</Command^>
  345. echo ^</Exec^>
  346. echo ^</Actions^>
  347. echo ^</Task^>
  348. ) >"%~dp0%Task_Name%.xml"
  349. ::
  350. :: Creating Windows Defender Update auto renewal task
  351. ::
  352. schtasks /delete /tn "%Task_Name%" /f 1>nul 2>nul
  353. schtasks /query /fo list 2>nul | findstr /i "%Task_Name%" 1>nul || (
  354. schtasks /create /tn "%Task_Name%" /ru "SYSTEM" /xml "%~dp0%Task_Name%.xml" >nul 2>&1 || (
  355. echo.&echo Creating Windows Defender Update %Task_Name% task errored.& echo Press any key to exit... & pause > nul &exit)
  356. del /f /q "%~dp0%Task_Name%.xml" >nul 2>&1)
  357. ::
  358. :: Create Windows Update Blocker "Wub_task" that sets your desired Windows Update service state at boot.
  359. ::
  360. :: Create Wub_task
  361. ::
  362. set "Task_Name=Wub_task"
  363. ::
  364. (
  365. echo ^<?xml version="1.0" encoding="UTF-16"?^>
  366. echo ^<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task"^>
  367. echo ^<RegistrationInfo^>
  368. echo ^<Date^>2016-02-18T08:29:39^</Date^>
  369. echo ^<Author^>pf100\rpo^</Author^>
  370. echo ^<URI^>wub_task^</URI^>
  371. echo ^</RegistrationInfo^>
  372. echo ^<Triggers^>
  373. echo ^<BootTrigger^>
  374. echo ^<StartBoundary^>2016-02-18T08:29:00^</StartBoundary^>
  375. echo ^<Enabled^>true^</Enabled^>
  376. echo ^</BootTrigger^>
  377. echo ^<LogonTrigger^>
  378. echo ^<Enabled^>true^</Enabled^>
  379. echo ^</LogonTrigger^>
  380. echo ^</Triggers^>
  381. echo ^<Principals^>
  382. echo ^<Principal id="Author"^>
  383. echo ^<UserId^>S-1-5-18^</UserId^>
  384. echo ^<RunLevel^>HighestAvailable^</RunLevel^>
  385. echo ^</Principal^>
  386. echo ^</Principals^>
  387. echo ^<Settings^>
  388. echo ^<MultipleInstancesPolicy^>IgnoreNew^</MultipleInstancesPolicy^>
  389. echo ^<DisallowStartIfOnBatteries^>false^</DisallowStartIfOnBatteries^>
  390. echo ^<StopIfGoingOnBatteries^>false^</StopIfGoingOnBatteries^>
  391. echo ^<AllowHardTerminate^>true^</AllowHardTerminate^>
  392. echo ^<StartWhenAvailable^>true^</StartWhenAvailable^>
  393. echo ^<RunOnlyIfNetworkAvailable^>false^</RunOnlyIfNetworkAvailable^>
  394. echo ^<IdleSettings^>
  395. echo ^<StopOnIdleEnd^>false^</StopOnIdleEnd^>
  396. echo ^<RestartOnIdle^>false^</RestartOnIdle^>
  397. echo ^</IdleSettings^>
  398. echo ^<AllowStartOnDemand^>true^</AllowStartOnDemand^>
  399. echo ^<Enabled^>true^</Enabled^>
  400. echo ^<Hidden^>false^</Hidden^>
  401. echo ^<RunOnlyIfIdle^>false^</RunOnlyIfIdle^>
  402. echo ^<WakeToRun^>false^</WakeToRun^>
  403. echo ^<ExecutionTimeLimit^>PT72H^</ExecutionTimeLimit^>
  404. echo ^<Priority^>7^</Priority^>
  405. echo ^</Settings^>
  406. echo ^<Actions Context="Author"^>
  407. echo ^<Exec^>
  408. echo ^<Command^>"%~dps0Wub.exe"^</Command^>
  409. echo ^<Arguments^>/d /p^</Arguments^>
  410. echo ^</Exec^>
  411. echo ^</Actions^>
  412. echo ^</Task^>
  413. )>"%~dp0%Task_Name%.xml"
  414. ::
  415. :: Creating Windows Update Blocker auto renewal task
  416. ::
  417. schtasks /delete /tn "%Task_Name%" /f 1>nul 2>nul
  418. schtasks /query /fo list 2>nul | findstr /i "%Task_Name%" 1>nul || (
  419. schtasks /create /tn "%Task_Name%" /ru "SYSTEM" /xml "%~dp0%Task_Name%.xml" >nul 2>&1 || (
  420. echo.&Creating Windows Update Blocker Auto-Renewal %Task_Name% task errored.& echo Press any key to exit... & pause > nul &exit)
  421. del /f /q "%~dp0%Task_Name%.xml" >nul 2>&1)
  422. ::::::::::::::::::::::::::::
  423. (
  424. echo if exist "%%~dp0wub.exe-backup" ren "%%~dp0wub.exe-backup" wub.exe
  425. echo "%%~dp0wub.exe" /d /p
  426. echo del "%%~dp0close.cmd" ^& exit
  427. )>"%~dp0close.cmd"
  428. "%~dp0wub.exe" /e >nul 2>&1
  429. :: Check OS and run correct version of WUMT
  430. for /f "tokens=2 delims==" %%a in ('wmic cpu get AddressWidth /value') do (set arch=%%a)
  431. IF %arch% == 32 (set "wumt=%~dp0wumt_x86.exe") else (set "wumt=%~dp0wumt_x64.exe")
  432. Start "" "%wumt%" -update "-onclose %~dp0close.cmd"
  433. ::The following line will be be used to run Windows Update Manager (WuMgr) instead of WUMT when I replace WUMT with WuMgr
  434. ::IF you feel adventurous go ahead and rem out the WUMT line above, and un-rem the wumgr.exe line below to replace WUMT with WuMgr.
  435. rem Start "" "%~dp0wumgr.exe" -update -online 7971f918-a847-4430-9279-4a52d1efe18d -onclose "%~dp0close.cmd"
  436. exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement