Advertisement
pf100

v2.4.5 WUMTWrapperScript.cmd

Jul 23rd, 2018
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.09 KB | None | 0 0
  1. @echo off
  2. mode con cols=85 lines=12
  3. Title WUMT Wrapper Script 2.4.5
  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. This script provides manual updating for Windows 10 including Home versions.
  13. Update Windows 10 on your schedule, not Microsoft's.
  14. I originally wrote this script for personal use because of the lack of update options with the
  15. original RTM release of Windows 10 Pro. I wanted to update Windows 10 when I had the free time
  16. to manually update, just like I did with previous versions of Windows that allowed me to
  17. set updates to manual, not when Microsoft forced it on me while I was busy using my computer.
  18. *******************************************************************
  19. WUMT is available here: https://forums.mydigitallife.net/threads/64939-Windows-Update-MiniTool
  20. Windows Update Blocker is available here: http://sordum.org/files/windows-update-blocker/old/Wub_v1.0.zip
  21. Only use Windows Update Blocker v1.0 with this script, not v1.1.
  22. *******************************************************************
  23. How it works: The script first checks if the OS is Windows 8.1 or older and if so
  24. it bypasses the Windows 10 Update Hijacker disable portion of the script.
  25. This script creates a smart Windows Defender Update task "WDU" that updates Windows
  26. Defender every 4 hours if it's running and enabled, and doesn't update it if it's not
  27. running and disabled, saving resources; auto-elevates, uninstalls and removes the
  28. Windows 10 Update Assistant, renames the %programfiles%\rempl* folder, resets and
  29. removes permissions from and disables these Update Hijackers:
  30. remsh.exe*
  31. osrss.dll
  32. UsoClient.exe
  33. WaaSMedic.exe
  34. WaasMedicSvc.dll
  35. WaaSMedicPS.dll
  36. WaaSAssessment.dll
  37. MusNotification.exe
  38. MusNotificationUx.exe
  39. SIHClient.exe
  40. * The following cause the windows update service to start if enabled in script and so are disabled:
  41. * pushtoinstall.dll
  42. * InstallServiceTasks.dll
  43. * InstallService.dll
  44. * compattelrunner.exe
  45. * Task - "\Microsoft\Windows\WindowsUpdate\Scheduled Start"
  46. * (pushtoinstall.dll being disabled makes it not possible to push apps to other pc's. If this, or
  47. any other issue is a problem, please report it to the support link at the top of this readme).
  48. makes sure the task "wub_task" is installed that runs wub at boot (to stop updates from turning
  49. updates back on), runs wub.exe and enables and starts the windows update service (wuauserv) if
  50. disabled (*wub can be disabled using the included Configurator.cmd script, leaving Windows Updates
  51. always running so you can use Store and Defender at any time), then runs the correct version of
  52. the Windows Update MiniTool in "auto search for updates" mode for your OS version's architecture
  53. (x86 or x64), then disables and stops wuauserv giving you full control. No more forced automatic
  54. updates or surprise reboots. This was written for Windows 10 Pro and Home, but works with all
  55. versions of Windows 10. Don't change any settings in lower left of WUMT while running the script.
  56. *******************************************************************
  57. I also included an uninstaller.cmd that deletes the WDU and wub_task tasks, deletes the WDU.cmd
  58. file used by WDU task, restores the rempl folder, resets Update Hijacker permissions to how they
  59. were originally, and turns off wub (if enabled) which turns the windows update service on automatic
  60. again, undoing everything done by the script. If you uninstall after having used the installer the
  61. script folder is removed also.
  62. *******************************************************************
  63. Configurator leaves the Update Hijackers disabled, but gives you the option of turning on the windows
  64. update service temporarily to use Store, or leave it on permanently to use Store anytime.
  65. *******************************************************************
  66. *If you need to install .Net 3.5 or use the Windows 10 Store or something that needs wuauserv
  67. running, run the script and after it enables wuauserv and starts WUMT, install what you need
  68. after WUMT checks for updates, before closing WUMT. If you ran the Configurator to "leave
  69. the Windows Update Service running at all times" you can ignore this note as the store will
  70. work at any time.
  71. *******************************************************************
  72. :start
  73. :::::::::::::::::::::::::::::::::::::::::
  74. :: Automatically check & get admin rights
  75. :::::::::::::::::::::::::::::::::::::::::
  76. :: ECHO.
  77. :: ECHO =============================
  78. :: ECHO Running Admin shell
  79. :: ECHO =============================
  80. :: Check Privileges
  81. :: Get Privileges
  82. :: and
  83. :: Invoke UAC for Privilege Escalation
  84. :: Notify if error escalating
  85. :: and prevent looping if escalation fails
  86. ::::::::::::::::::::::::::::
  87. set "params=Problem_with_elevating_UAC_for_Administrator_Privileges"&if exist "%temp%\getadmin.vbs" del "%temp%\getadmin.vbs"
  88. fsutil dirty query %systemdrive% >nul 2>&1 && goto :GotPrivileges
  89. :: The following test is to avoid infinite looping if elevating UAC for Administrator Privileges failed
  90. 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)
  91. cmd /u /c echo Set UAC = CreateObject^("Shell.Application"^) : UAC.ShellExecute "%~0", "%params%", "", "runas", 1 > "%temp%\getadmin.vbs"&cscript //nologo "%temp%\getadmin.vbs"&exit
  92. :GotPrivileges
  93. ::::::::::::::::::::::::::::
  94. ::START
  95. ::Uninstall and remove Windows 10 Update assistant.
  96. ::Disable Windows Update Service until script menu screen.
  97. ::Reset (in case of wrong Permissions), remove Permissions from and
  98. ::disable "Update Hijackers"
  99. ::Install wub_task (prevents Windows Update service from starting after installing updates and rebooting).
  100. ::If Windows 10 install WDU task to perform automatic windows defender updates.
  101. ::Enable and start the Windows Update Service (wuauserv).
  102. ::Run the correct version of WUMT for your architecture.
  103. ::Start WUMT in "auto-check for updates" mode.
  104. ::After updates are completed and WUMT is closed and/or the "reboot"
  105. ::button in WUMT is pressed, silently run wub.exe and disable and stop wuauserv
  106. ::::::::::::::::::::::::::::
  107. @echo off
  108. cls
  109. rem echo. & echo. & echo. & echo.
  110. rem echo. & echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Initializing script...
  111. rem Get Windows OS build number
  112. for /f "tokens=2 delims==" %%a in ('wmic path Win32_OperatingSystem get BuildNumber /value') do (
  113. set /a WinBuild=%%a
  114. )
  115. rem Test for Windows versions below Windows 10 and if so just install wub_task and start wumt.
  116. if %winbuild% LEQ 9600 (
  117. rem Sanity check if script copied over different version of script:
  118. rem If somehow both files "wub.exe" and "wub.exe-backup" exist, delete "wub.exe-backup"
  119. rem If only wub.exe-backup exists, rename it to wub.exe
  120. (if exist "%~dp0wub.exe" (del "%~dp0wub.exe-backup" /f /q) else (ren "%~dp0wub.exe-backup" wub.exe)) >nul 2>&1
  121.  
  122. call :Install_wub_task
  123. goto :StartWUMT
  124. )
  125. ::Remove Update Assistant
  126. if exist "%systemdrive%\Windows10Upgrade\Windows10UpgraderApp.exe" ( echo Windows 10 Update Assistant detected. Preparing to uninstall.
  127. echo The "Windows 10 Update Assistant has stopped working" dialog box may pop up. If so, just close it.
  128. echo Press a key to acknowledge this and please wait for the uninstall to finish.
  129. echo Script will continue after uninstall and removal is completed...
  130. pause > nul
  131. echo Uninstalling Windows 10 Update Assistant...
  132. %systemdrive%\Windows10Upgrade\Windows10UpgraderApp.exe /forceuninstall
  133. timeout /t 10 /nobreak >nul 2>&1
  134. del %systemroot%\UpdateAssistant\*.* /f /q >nul 2>&1
  135. rmdir %systemroot%\UpdateAssistant /s /q >nul 2>&1
  136. del %SystemDrive%\Windows10Upgrade\*.* /f /q >nul 2>&1
  137. rmdir %SystemDrive%\Windows10Upgrade /s /q >nul 2>&1
  138. cls
  139. echo Windows 10 Update Assistant removed.
  140. echo Press a key to continue...
  141. pause > nul )
  142. del %systemroot%\UpdateAssistantV2\*.* /f /q >nul 2>&1
  143. rmdir %systemroot%\UpdateAssistantV2 /s /q >nul 2>&1
  144. cls
  145. ::::::::::::::::::::::::::::
  146. :: Disable the Windows Update Scheduled Start task. It starts the update service
  147. :: for no good reason if the script is set to enable the update service but service is not running.
  148. :: I'm having to force the task to stay disabled or it turns itself back on.
  149. takeown /f "%systemroot%\System32\Tasks\Microsoft\Windows\WindowsUpdate\Scheduled Start" /a >nul 2>&1
  150. schtasks /change /tn "\Microsoft\Windows\WindowsUpdate\Scheduled Start" /disable >nul 2>&1
  151. icacls "%systemroot%\System32\Tasks\Microsoft\Windows\WindowsUpdate\Scheduled Start" /reset >nul 2>&1
  152. icacls "%systemroot%\System32\Tasks\Microsoft\Windows\WindowsUpdate\Scheduled Start" /inheritance:r /remove *S-1-5-32-544 *S-1-5-11 *S-1-5-32-545 *S-1-5-18 >nul 2>&1
  153. ::::::::::::::::::::::::::::
  154. :: (placeholder) Disable all UpdateOrchestrator tasks (used as example) and prevent them from being enabled (for possible future use.)
  155. rem This is just a working example and can be used to disable individual tasks or entire folders of tasks.
  156. rem takeown /f "%systemroot%\System32\Tasks\Microsoft\Windows\UpdateOrchestrator\*" /a >nul 2>&1
  157. rem icacls "%systemroot%\System32\Tasks\Microsoft\Windows\UpdateOrchestrator\*" /q /c /t /reset >nul 2>&1
  158. rem powershell -command "& {Get-ScheduledTask -TaskPath '\Microsoft\Windows\UpdateOrchestrator\' | Disable-ScheduledTask}" >nul 2>&1
  159. rem icacls "%systemroot%\System32\Tasks\Microsoft\Windows\UpdateOrchestrator\*" /inheritance:r /remove *S-1-5-32-544 *S-1-5-11 *S-1-5-32-545 *S-1-5-18 >nul 2>&1
  160. ::
  161. :: Re-enable all UpdateOrchestrator tasks and reset owner to System (in uninstaller):
  162. rem takeown /f "%systemroot%\System32\Tasks\Microsoft\Windows\UpdateOrchestrator\*" /a
  163. rem icacls "%systemroot%\System32\Tasks\Microsoft\Windows\UpdateOrchestrator\*" /q /c /t /reset
  164. rem powershell -command "& {Get-ScheduledTask -TaskPath '\Microsoft\Windows\UpdateOrchestrator\' | Enable-ScheduledTask}"
  165. rem icacls "%systemroot%\System32\Tasks\Microsoft\Windows\UpdateOrchestrator\*" /setowner *S-1-5-18
  166. ::::::::::::::::::::::::::::
  167. ::Create automatic Windows Defender Update "WDU" task that updates Defender only if it's enabled and running.
  168. ::Create Windows Update Blocker "Wub_task" that sets your desired Windows Update service state at boot.
  169. cls
  170. echo. & echo. & echo. & echo.
  171. echo. & echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Initializing script...
  172. call :Install_wub_task >nul 2>&1
  173. cls
  174. echo. & echo. & echo. & echo.
  175. echo. & echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Initializing script...
  176. call :Install_wdu_task >nul 2>&1
  177. ::::::::::::::::::::::::::::
  178. ::In case new script is copied over old script while wub.exe-backup exists, then wub.exe would exist too,
  179. ::so check if windows update service is disabled or not and then correctly delete either wub.exe or wub.exe-backup.
  180. Reg query "HKLM\SYSTEM\CurrentControlSet\Services\wuauserv" /v "Start" | find "4" >nul 2>&1
  181. 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)
  182. ::::::::::::::::::::::::::::
  183. ::If somehow both files "wub.exe" and "wub.exe-backup" exist after the previous check, delete "wub.exe-backup"
  184. if exist "%~dp0wub.exe" if exist "%~dp0wub.exe-backup" del "%~dp0wub.exe-backup" /f /q >nul 2>&1
  185. ::::::::::::::::::::::::::::
  186. ::Set list (s32list) of update hijacker files to be disabled, then disable everything in the list.
  187. set s32list=EOSNotify.exe WaaSMedic.exe WaasMedicSvc.dll WaaSMedicPS.dll WaaSAssessment.dll UsoClient.exe pushtoinstall.dll
  188. set s32list=%s32list% SIHClient.exe MusNotificationUx.exe MusNotification.exe osrss.dll InstallServiceTasks.dll
  189. set s32list=%s32list% InstallService.dll compattelrunner.exe
  190. set s32=%systemroot%\System32
  191. for %%# in (%s32list%) do (
  192. takeown /f "%s32%\%%#" /a >nul 2>&1
  193. icacls "%s32%\%%#" /reset >nul 2>&1
  194. 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
  195. )
  196. ::::::::::::::::::::::::::::
  197. ::Disable update service unless overriden with Configurator which renames wub.exe to wub.exe-backup
  198. ::in which case this command does nothing by design.
  199. "%~dp0wub.exe" /d /p >nul 2>&1
  200. ::::::::::::::::::::::::::::
  201. ::Disable remsh
  202. taskkill /im remsh.exe /f >nul 2>&1
  203. if exist "%ProgramFiles%\rempl" rmdir /s /q "%ProgramFiles%\rempl-backup" >nul 2>&1
  204. ren "%ProgramFiles%\rempl" rempl-backup >nul 2>&1
  205. ::::::::::::::::::::::::::::
  206. ::Windows Update Service Configurator
  207. cls
  208. echo. & echo. & echo. & echo.
  209. echo. & echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Initializing Configurator...
  210. Reg query "HKLM\SYSTEM\CurrentControlSet\Services\wuauserv" /v "Start" | find "4" >nul 2>&1
  211. if %errorlevel% == 1 goto wuenable
  212. ::disable windows update service except when wumt is run.
  213. :wudisable
  214. ren "%~dp0wub.exe-backup" wub.exe >nul 2>&1
  215. timeout /t 2 /nobreak >nul 2>&1
  216. "%~dp0wub.exe" /d /p >nul 2>&1
  217. timeout /t 2 /nobreak >nul 2>&1
  218. cls
  219. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ WUMT Wrapper Script Windows Update Service Configurator & echo.
  220. echo ^ ^ ^ ^ ^ ^ ---^>^>^> Windows Update Service is DISABLED and stopped ^(default^) ^<^<^<---
  221. echo. & echo [E]nable Update Service to allow Windows Store.
  222. echo. & echo [C]ontinue script if above Update Service Status is okay...
  223. echo. & echo E[x]it script if you're just verifying or changing the update service status...
  224. echo. & echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Please select [E], [C], or [X]
  225. CHOICE /C ECX /M "Your choice?:" >nul 2>&1
  226. if %errorlevel%==3 (exit)
  227. if %errorlevel%==2 (goto splash)
  228. cls
  229. echo. & echo. & echo.
  230. echo. & echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Please wait while Windows Update Service is enabled.
  231. echo. & echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ This will take a few seconds...
  232. timeout /t 2 /nobreak >nul 2>&1
  233. ::enable windows update service
  234. :wuenable
  235. ren "%~dp0wub.exe-backup" wub.exe >nul 2>&1
  236. timeout /t 2 /nobreak >nul 2>&1
  237. "%~dp0wub.exe" /e >nul 2>&1
  238. timeout /t 2 /nobreak >nul 2>&1
  239. ren "%~dp0wub.exe" wub.exe-backup >nul 2>&1
  240. timeout /t 2 /nobreak >nul 2>&1
  241. net stop wuauserv >nul 2>&1
  242. cls
  243. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ WUMT Wrapper Script Windows Update Service Configurator & echo.
  244. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ---^>^>^> Windows Update Service is ENABLED ^(for Store^) ^<^<^<---
  245. echo. & echo [D]isable Update Service and only allow to run during updates with script (default).
  246. echo. & echo [C]ontinue script if above Update Service Status is okay...
  247. echo. & echo E[x]it script if you're just verifying or changing the update service status...
  248. echo. & echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Please select [D], [C], or [X]
  249. CHOICE /C DCX /M "Your choice?:" >nul 2>&1
  250. if %errorlevel%==3 (exit)
  251. if %errorlevel%==2 (goto splash)
  252. if %errorlevel%==1 (
  253. cls
  254. echo. & echo. & echo.
  255. echo. & echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Please wait while Windows Update Service is disabled.
  256. echo. & echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ This will take a few seconds...
  257. timeout /t 2 /nobreak >nul 2>&1
  258. goto wudisable
  259. )
  260. ::::::::::::::::::::::::::::
  261. :splash
  262. mode con cols=56 lines=33
  263. cls
  264. echo ********************************************************
  265. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Welcome to manual updates! & echo.
  266. echo Press any key to check for updates, or close this screen
  267. echo ^ ^ ^ ^ ^ ^ ^ to cancel and leave updates turned off
  268. echo ^ ^ ^ ^ ^ ^ ^ (unless overridden with configurator). & echo.
  269. echo ********************************************************
  270. echo Automatic updates are now turned off (unless overriden
  271. echo with Configurator). This script automates the update
  272. echo process. It automatically disables a range of "Update
  273. echo Hijackers" such as: osrss, remsh, Uso, WaaS, SIH, and
  274. echo Update Assistant. Enables and starts only the Windows
  275. echo Update Service, runs the Windows Update MiniTool (WUMT).
  276. echo After updates, stops and disables the Windows Update
  277. echo service (unless overriden with Configurator). The
  278. echo included uninstaller undoes script changes. Closing WUMT
  279. echo at any time disables updates again (unless overriden
  280. echo with Configurator); however, if WUMT is already offering
  281. echo updates, you need to hide them and/or install them
  282. echo one-by-one before closing WUMT or it may install them
  283. echo without asking next time. Don't change WUMT settings
  284. echo while running this script. If an update requires a
  285. echo reboot, re-run the script after the reboot and just
  286. echo close the first screen to make sure the "Update
  287. echo Hijackers" stay off. Enable update service in
  288. echo Configurator in script to use the Store at the risk of
  289. echo possible unwanted updates if you leave it on. Better to
  290. echo enable updates, use store, then disable updates. Use at
  291. echo your discretion.
  292. echo ********************************************************
  293. echo ^ ^ ^ ^ Press any key to run Windows Update MiniTool...
  294. pause > nul
  295. :StartWUMT
  296. "%~dp0wub.exe" /e >nul 2>&1
  297. cls
  298. :: Check OS and run correct version of WUMT
  299. for /f "tokens=2 delims==" %%a in ('wmic cpu get AddressWidth /value') do (set arch=%%a)
  300. IF %arch% == 32 (set "wumt=%~dp0wumt_x86.exe") else (set "wumt=%~dp0wumt_x64.exe")
  301. Start "" "%wumt%" -update "-onclose %~dp0wub.exe /d /p"
  302. goto :EOF
  303. ::
  304. ::
  305. :Install_Wub_task
  306. set "Task_Name=wub_task"
  307. ::
  308. :: Create wbu_task.xml
  309. ::
  310. (
  311. echo ^<?xml version="1.0" encoding="UTF-16"?^>
  312. echo ^<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task"^>
  313. echo ^<RegistrationInfo^>
  314. echo ^<Date^>2018-02-18T08:29:39^</Date^>
  315. echo ^<Author^>pf100\rpo^</Author^>
  316. echo ^<URI^>\wub_task^</URI^>
  317. echo ^</RegistrationInfo^>
  318. echo ^<Triggers^>
  319. echo ^<BootTrigger^>
  320. echo ^<StartBoundary^>2016-05-12T08:29:00^</StartBoundary^>
  321. echo ^<Enabled^>true^</Enabled^>
  322. echo ^</BootTrigger^>
  323. echo ^</Triggers^>
  324. echo ^<Principals^>
  325. echo ^<Principal id="Author"^>
  326. echo ^<UserId^>S-1-5-18^</UserId^>
  327. echo ^<RunLevel^>HighestAvailable^</RunLevel^>
  328. echo ^</Principal^>
  329. echo ^</Principals^>
  330. echo ^<Settings^>
  331. echo ^<MultipleInstancesPolicy^>IgnoreNew^</MultipleInstancesPolicy^>
  332. echo ^<DisallowStartIfOnBatteries^>false^</DisallowStartIfOnBatteries^>
  333. echo ^<StopIfGoingOnBatteries^>false^</StopIfGoingOnBatteries^>
  334. echo ^<AllowHardTerminate^>true^</AllowHardTerminate^>
  335. echo ^<StartWhenAvailable^>false^</StartWhenAvailable^>
  336. echo ^<RunOnlyIfNetworkAvailable^>false^</RunOnlyIfNetworkAvailable^>
  337. echo ^<IdleSettings^>
  338. echo ^<StopOnIdleEnd^>true^</StopOnIdleEnd^>
  339. echo ^<RestartOnIdle^>false^</RestartOnIdle^>
  340. echo ^</IdleSettings^>
  341. echo ^<AllowStartOnDemand^>true^</AllowStartOnDemand^>
  342. echo ^<Enabled^>true^</Enabled^>
  343. echo ^<Hidden^>false^</Hidden^>
  344. echo ^<RunOnlyIfIdle^>false^</RunOnlyIfIdle^>
  345. echo ^<WakeToRun^>false^</WakeToRun^>
  346. echo ^<ExecutionTimeLimit^>PT72H^</ExecutionTimeLimit^>
  347. echo ^<Priority^>7^</Priority^>
  348. echo ^</Settings^>
  349. echo ^<Actions Context="Author"^>
  350. echo ^<Exec^>
  351. echo ^<Command^>"%~dp0wub.exe"^</Command^>
  352. echo ^<Arguments^>/d /p^</Arguments^>
  353. echo ^</Exec^>
  354. echo ^</Actions^>
  355. echo ^</Task^>
  356. )>"%~dp0%Task_Name%.xml"
  357. schtasks /delete /tn "%Task_Name%" /f 1>nul 2>nul
  358. schtasks /query /fo list 2>nul | findstr /i "%Task_Name%" 1>nul || (
  359. echo.&echo Creating Windows Update Blocker Auto-Renewal task %Task_Name%.
  360. schtasks /create /tn "%Task_Name%" /ru "SYSTEM" /xml "%~dp0%Task_Name%.xml" >nul 2>&1 || (
  361. echo.&Creating Windows Update Blocker Auto-Renewal %Task_Name% task errored.& echo Press any key to exit... & pause > nul &exit)
  362. rem echo Windows Update Blocker Auto-Renewal %Task_Name% created.
  363. del /f /q "%~dp0%Task_Name%.xml" >nul 2>&1)
  364. exit /b
  365. ::
  366. ::
  367. :Install_wdu_task
  368. set "Task_Name=WDU"
  369. ::
  370. :: Create WDU.cmd
  371. ::
  372. (
  373. echo rem Don't run this file. It's for use by wrapper script.
  374. echo cd /d "%%~dp0"
  375. echo sc query ^| find /i "windefend" ^> nul ^& if errorlevel 1 ^(exit^)
  376. echo if not exist wub.exe-backup ^(wub.exe /e^)
  377. echo "%ProgramFiles%\Windows Defender\MpCmdRun.exe" -SignatureUpdate
  378. echo if not exist wub.exe-backup ^(wub.exe /d /p^)
  379. echo exit
  380. )> "%~dp0%Task_Name%.cmd"
  381. ::
  382. :: Create WDU.xml
  383. ::
  384. (
  385. echo ^<?xml version="1.0" encoding="UTF-16"?^>
  386. echo ^<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task"^>
  387. echo ^<RegistrationInfo^>
  388. echo ^<Date^>2018-05-12T00:01:00^</Date^>
  389. echo ^<Author^>pf100\rpo^</Author^>
  390. echo ^<URI^>\WDU^</URI^>
  391. echo ^</RegistrationInfo^>
  392. echo ^<Triggers^>
  393. echo ^<CalendarTrigger^>
  394. echo ^<Repetition^>
  395. echo ^<Interval^>PT4H^</Interval^>
  396. echo ^<StopAtDurationEnd^>false^</StopAtDurationEnd^>
  397. echo ^</Repetition^>
  398. echo ^<StartBoundary^>2016-05-12T00:01:00.0^</StartBoundary^>
  399. echo ^<Enabled^>true^</Enabled^>
  400. echo ^<ScheduleByDay^>
  401. echo ^<DaysInterval^>1^</DaysInterval^>
  402. echo ^</ScheduleByDay^>
  403. echo ^</CalendarTrigger^>
  404. echo ^</Triggers^>
  405. echo ^<Principals^>
  406. echo ^<Principal id="Author"^>
  407. echo ^<UserId^>S-1-5-18^</UserId^>
  408. echo ^<RunLevel^>HighestAvailable^</RunLevel^>
  409. echo ^</Principal^>
  410. echo ^</Principals^>
  411. echo ^<Settings^>
  412. echo ^<MultipleInstancesPolicy^>IgnoreNew^</MultipleInstancesPolicy^>
  413. echo ^<DisallowStartIfOnBatteries^>false^</DisallowStartIfOnBatteries^>
  414. echo ^<StopIfGoingOnBatteries^>false^</StopIfGoingOnBatteries^>
  415. echo ^<AllowHardTerminate^>true^</AllowHardTerminate^>
  416. echo ^<StartWhenAvailable^>true^</StartWhenAvailable^>
  417. echo ^<RunOnlyIfNetworkAvailable^>true^</RunOnlyIfNetworkAvailable^>
  418. echo ^<IdleSettings^>
  419. echo ^<StopOnIdleEnd^>false^</StopOnIdleEnd^>
  420. echo ^<RestartOnIdle^>false^</RestartOnIdle^>
  421. echo ^</IdleSettings^>
  422. echo ^<AllowStartOnDemand^>true^</AllowStartOnDemand^>
  423. echo ^<Enabled^>true^</Enabled^>
  424. echo ^<Hidden^>false^</Hidden^>
  425. echo ^<RunOnlyIfIdle^>false^</RunOnlyIfIdle^>
  426. echo ^<WakeToRun^>false^</WakeToRun^>
  427. echo ^<ExecutionTimeLimit^>PT72H^</ExecutionTimeLimit^>
  428. echo ^<Priority^>7^</Priority^>
  429. echo ^</Settings^>
  430. echo ^<Actions Context="Author"^>
  431. echo ^<Exec^>
  432. echo ^<Command^>"%~dp0WDU.cmd"^</Command^>
  433. echo ^</Exec^>
  434. echo ^</Actions^>
  435. echo ^</Task^>
  436. ) >"%~dp0%Task_Name%.xml"
  437. rem
  438. rem Creating Windows Defender Update auto renewal task
  439. rem
  440. schtasks /delete /tn "%Task_Name%" /f 1>nul 2>nul
  441. schtasks /query /fo list 2>nul | findstr /i "%Task_Name%" 1>nul || (
  442. echo.&echo Creating Windows Defender Update task %Task_Name%.
  443. schtasks /create /tn "%Task_Name%" /ru "SYSTEM" /xml "%~dp0%Task_Name%.xml" >nul 2>&1 || (
  444. echo.&echo Creating Windows Defender Update %Task_Name% task errored.& echo Press any key to exit... & pause > nul &exit)
  445. rem echo Windows Defender Update task %Task_Name% created.
  446. del /f /q "%~dp0%Task_Name%.xml" >nul 2>&1)
  447. exit /b
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement