Advertisement
pf100

v2.4.2 WUMTWrapperScript

Jul 8th, 2018
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.61 KB | None | 0 0
  1. @echo off
  2. mode con cols=85 lines=12
  3. Title WUMT Wrapper Script 2.4.2
  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 if it's running and enabled, and doesn't update it if it's not running and disabled,
  27. auto-elevates, uninstalls and removes the Windows 10 Update Assistant, renames the
  28. %programfiles%\rempl* folder, resets and removes permissions from and disables these
  29. 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. makes sure the task "wub_task" is installed that runs wub at boot (to stop updates from turning
  41. updates back on), runs wub.exe and enables and starts the windows update service (wuauserv) if
  42. disabled (*wub can be disabled using the included Configurator.cmd script, leaving Windows Updates
  43. always running so you can use Store and Defender at any time), then runs the correct version of
  44. the Windows Update MiniTool in "auto search for updates" mode for your OS version's architecture
  45. (x86 or x64), then disables and stops wuauserv giving you full control. No more forced automatic
  46. updates or surprise reboots. This was written for Windows 10 Pro and Home, but works with all
  47. versions of Windows 10. Don't change any settings in lower left of WUMT while running the script.
  48. *******************************************************************
  49. I also included an uninstaller.cmd that deletes the WDU and wub_task tasks, deletes the WDU.cmd
  50. file used by WDU task, restores the rempl folder, resets Update Hijacker permissions to how they
  51. were originally, and turns off wub (if enabled) which turns the windows update service on automatic
  52. again, undoing everything done by the script. If you uninstall after having used the installer the
  53. script folder is removed also.
  54. *******************************************************************
  55. Configurator leaves the Update Hijackers disabled, but gives you the option of turning on the windows
  56. update service temporarily to use Store, or leave it on permanently to use Store anytime.
  57. *******************************************************************
  58. *If you need to install .Net 3.5 or use the Windows 10 Store or something that needs wuauserv
  59. running, run the script and after it enables wuauserv and starts WUMT, install what you need
  60. after WUMT checks for updates, before closing WUMT. If you ran the Configurator to "leave
  61. the Windows Update Service running at all times" you can ignore this note as the store will
  62. work at any time.
  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. ::START
  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. ::If Windows 10 install WDU task to perform automatic windows defender updates.
  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. echo. & echo. & echo. & echo.
  102. echo. & echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Disabling update hijackers...
  103. rem Get Windows OS build number
  104. for /f "tokens=2 delims==" %%a in ('wmic path Win32_OperatingSystem get BuildNumber /value') do (
  105. set /a WinBuild=%%a
  106. )
  107. rem Test for Windows versions below Windows 10 and if so just install wub_task and start wumt.
  108. if %winbuild% LEQ 9600 (
  109. rem Sanity check if script copied over different version of script:
  110. rem If somehow both files "wub.exe" and "wub.exe-backup" exist, delete "wub.exe-backup"
  111. rem If only wub.exe-backup exists, rename it to wub.exe
  112. (if exist "%~dp0wub.exe" (del "%~dp0wub.exe-backup" /f /q) else (ren "%~dp0wub.exe-backup" wub.exe)) >nul 2>&1
  113.  
  114. call :Install_wub_task
  115. goto :StartWUMT
  116. )
  117. ::Remove Update Assistant
  118. if exist "%systemdrive%\Windows10Upgrade\Windows10UpgraderApp.exe" ( echo Windows 10 Update Assistant detected. Preparing to uninstall.
  119. echo The "Windows 10 Update Assistant has stopped working" dialog box may pop up. If so, just close it.
  120. echo Press a key to acknowledge this and please wait for the uninstall to finish.
  121. echo Script will continue after uninstall and removal is completed...
  122. pause > nul
  123. echo Uninstalling Windows 10 Update Assistant...
  124. %systemdrive%\Windows10Upgrade\Windows10UpgraderApp.exe /forceuninstall
  125. timeout /t 10 /nobreak >nul 2>&1
  126. del %systemroot%\UpdateAssistant\*.* /f /q >nul 2>&1
  127. rmdir %systemroot%\UpdateAssistant /s /q >nul 2>&1
  128. del %SystemDrive%\Windows10Upgrade\*.* /f /q >nul 2>&1
  129. rmdir %SystemDrive%\Windows10Upgrade /s /q >nul 2>&1
  130. cls
  131. echo Windows 10 Update Assistant removed.
  132. echo Press a key to continue...
  133. pause > nul )
  134. del %systemroot%\UpdateAssistantV2\*.* /f /q >nul 2>&1
  135. rmdir %systemroot%\UpdateAssistantV2 /s /q >nul 2>&1
  136. cls
  137. ::::::::::::::::::::::::::::
  138. :: (placeholder) Disable all UpdateOrchestrator tasks (used as example) and prevent them from being enabled (for possible future use.)
  139. rem This is just a working example and can be used to disable individual tasks or entire folders of tasks.
  140. rem takeown /f "%systemroot%\System32\Tasks\Microsoft\Windows\UpdateOrchestrator\*" /a >nul 2>&1
  141. rem icacls "%systemroot%\System32\Tasks\Microsoft\Windows\UpdateOrchestrator\*" /q /c /t /reset >nul 2>&1
  142. rem powershell -command "& {Get-ScheduledTask -TaskPath '\Microsoft\Windows\UpdateOrchestrator\' | Disable-ScheduledTask}" >nul 2>&1
  143. 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
  144. ::
  145. :: Re-enable all UpdateOrchestrator tasks and reset owner to System (in uninstaller):
  146. rem takeown /f "%systemroot%\System32\Tasks\Microsoft\Windows\UpdateOrchestrator\*" /a
  147. rem icacls "%systemroot%\System32\Tasks\Microsoft\Windows\UpdateOrchestrator\*" /q /c /t /reset
  148. rem powershell -command "& {Get-ScheduledTask -TaskPath '\Microsoft\Windows\UpdateOrchestrator\' | Enable-ScheduledTask}"
  149. rem icacls "%systemroot%\System32\Tasks\Microsoft\Windows\UpdateOrchestrator\*" /setowner *S-1-5-18
  150. ::::::::::::::::::::::::::::
  151. ::Create automatic Windows Defender Update "WDU" task that updates Defender only if it's enabled and running.
  152. ::Create Windows Update Blocker "Wub_task" that sets your desired Windows Update service state at boot.
  153. cls
  154. echo. & echo. & echo. & echo.
  155. echo. & echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Disabling update hijackers...
  156. call :Install_wub_task >nul 2>&1
  157. cls
  158. echo. & echo. & echo. & echo.
  159. echo. & echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Disabling update hijackers...
  160. call :Install_wdu_task >nul 2>&1
  161. ::::::::::::::::::::::::::::
  162. ::In case new script is copied over old script while wub.exe-backup exists, then wub.exe would exist too,
  163. ::so check if windows update service is disabled or not and then correctly delete either wub.exe or wub.exe-backup.
  164. Reg query "HKLM\SYSTEM\CurrentControlSet\Services\wuauserv" /v "Start" | find "4" >nul 2>&1
  165. 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)
  166. ::::::::::::::::::::::::::::
  167. ::If somehow both files "wub.exe" and "wub.exe-backup" exist after the previous check, delete "wub.exe-backup"
  168. if exist "%~dp0wub.exe" if exist "%~dp0wub.exe-backup" del "%~dp0wub.exe-backup" /f /q >nul 2>&1
  169. ::::::::::::::::::::::::::::
  170. ::Disable update service unless overriden with Configurator which renames wub.exe to wub.exe-backup
  171. ::in which case this command does nothing by design.
  172. "%~dp0wub.exe" /d /p >nul 2>&1
  173. ::::::::::::::::::::::::::::
  174. ::Set list (s32list) of update hijacker files to be disabled, then disable anything in the list.
  175. set s32list=EOSNotify.exe WaaSMedic.exe WaasMedicSvc.dll WaaSMedicPS.dll WaaSAssessment.dll UsoClient.exe
  176. set s32list=%s32list% SIHClient.exe MusNotificationUx.exe MusNotification.exe osrss.dll
  177. set s32=%systemroot%\System32
  178. for %%# in (%s32list%) do (
  179. takeown /f "%s32%\%%#" /a >nul 2>&1
  180. icacls "%s32%\%%#" /reset >nul 2>&1
  181. 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
  182. )
  183. ::::::::::::::::::::::::::::
  184. ::Disable remsh
  185. taskkill /im remsh.exe /f >nul 2>&1
  186. if exist "%ProgramFiles%\rempl" rmdir /s /q "%ProgramFiles%\rempl-backup" >nul 2>&1
  187. ren "%ProgramFiles%\rempl" rempl-backup >nul 2>&1
  188. ::::::::::::::::::::::::::::
  189. ::Windows Update Service Configurator
  190. cls
  191. echo. & echo. & echo. & echo.
  192. echo. & echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Initializing Configurator...
  193. Reg query "HKLM\SYSTEM\CurrentControlSet\Services\wuauserv" /v "Start" | find "4" >nul 2>&1
  194. if %errorlevel% == 1 goto wuenable
  195. ::disable windows update service except when wumt is run.
  196. :wudisable
  197. ren "%~dp0wub.exe-backup" wub.exe >nul 2>&1
  198. timeout /t 2 /nobreak >nul 2>&1
  199. "%~dp0wub.exe" /d /p >nul 2>&1
  200. timeout /t 2 /nobreak >nul 2>&1
  201. cls
  202. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ WUMT Wrapper Script Windows Update Service Configurator & echo.
  203. echo ^ ^ ^ ^ ^ ^ ---^>^>^> Windows Update Service is DISABLED and stopped ^(default^) ^<^<^<---
  204. echo. & echo [E]nable Update Service to allow Windows Store.
  205. echo. & echo [C]ontinue script if above Update Service Status is okay...
  206. echo. & echo E[x]it script if you're just verifying or changing the update service status...
  207. echo. & echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Please select [E], [C], or [X]
  208. CHOICE /C ECX /M "Your choice?:" >nul 2>&1
  209. if %errorlevel%==3 (exit)
  210. if %errorlevel%==2 (goto splash)
  211. cls
  212. echo. & echo. & echo.
  213. echo. & echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Please wait while Windows Update Service is enabled.
  214. echo. & echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ This will take a few seconds...
  215. timeout /t 2 /nobreak >nul 2>&1
  216. ::enable windows update service
  217. :wuenable
  218. ren "%~dp0wub.exe-backup" wub.exe >nul 2>&1
  219. timeout /t 2 /nobreak >nul 2>&1
  220. "%~dp0wub.exe" /e >nul 2>&1
  221. timeout /t 2 /nobreak >nul 2>&1
  222. ren "%~dp0wub.exe" wub.exe-backup >nul 2>&1
  223. timeout /t 2 /nobreak >nul 2>&1
  224. cls
  225. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ WUMT Wrapper Script Windows Update Service Configurator & echo.
  226. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ---^>^>^> Windows Update Service is ENABLED ^(for Store^) ^<^<^<---
  227. echo. & echo [D]isable Update Service and only allow to run during updates with script (default).
  228. echo. & echo [C]ontinue script if above Update Service Status is okay...
  229. echo. & echo E[x]it script if you're just verifying or changing the update service status...
  230. echo. & echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Please select [D], [C], or [X]
  231. CHOICE /C DCX /M "Your choice?:" >nul 2>&1
  232. if %errorlevel%==3 (exit)
  233. if %errorlevel%==2 (goto splash)
  234. if %errorlevel%==1 (
  235. cls
  236. echo. & echo. & echo.
  237. echo. & echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Please wait while Windows Update Service is disabled.
  238. echo. & echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ This will take a few seconds...
  239. timeout /t 2 /nobreak >nul 2>&1
  240. goto wudisable
  241. )
  242. ::::::::::::::::::::::::::::
  243. :splash
  244. mode con cols=56 lines=33
  245. cls
  246. echo ********************************************************
  247. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Welcome to manual updates! & echo.
  248. echo Press any key to check for updates, or close this screen
  249. echo ^ ^ ^ ^ ^ ^ ^ to cancel and leave updates turned off
  250. echo ^ ^ ^ ^ ^ ^ ^ (unless overridden with configurator). & echo.
  251. echo ********************************************************
  252. echo Automatic updates are now turned off (unless overriden
  253. echo with Configurator). This script automates the update
  254. echo process. It automatically disables a range of "Update
  255. echo Hijackers" such as: osrss, remsh, Uso, WaaS, SIH, and
  256. echo Update Assistant. Enables and starts only the Windows
  257. echo Update Service, runs the Windows Update MiniTool (WUMT).
  258. echo After updates, stops and disables the Windows Update
  259. echo service (unless overriden with Configurator). The
  260. echo included uninstaller undoes script changes. Closing WUMT
  261. echo at any time disables updates again (unless overriden
  262. echo with Configurator); however, if WUMT is already offering
  263. echo updates, you need to hide them and/or install them
  264. echo one-by-one before closing WUMT or it may install them
  265. echo without asking next time. Don't change WUMT settings
  266. echo while running this script. If an update requires a
  267. echo reboot, re-run the script after the reboot and just
  268. echo close the first screen to make sure the "Update
  269. echo Hijackers" stay off. Enable update service in
  270. echo Configurator in script to use the Store at the risk of
  271. echo possible unwanted updates if you leave it on. Better to
  272. echo enable updates, use store, then disable updates. Use at
  273. echo your discretion.
  274. echo ********************************************************
  275. echo ^ ^ ^ ^ Press any key to run Windows Update MiniTool...
  276. pause > nul
  277. :StartWUMT
  278. "%~dp0wub.exe" /e >nul 2>&1
  279. cls
  280. :: Check OS and run correct version of WUMT
  281. for /f "tokens=2 delims==" %%a in ('wmic cpu get AddressWidth /value') do (set arch=%%a)
  282. IF %arch% == 32 (set "wumt=%~dp0wumt_x86.exe") else (set "wumt=%~dp0wumt_x64.exe")
  283. Start "" "%wumt%" -update "-onclose %~dp0wub.exe /d /p"
  284. goto :EOF
  285. ::
  286. ::
  287. :Install_Wub_task
  288. set "Task_Name=wub_task"
  289. ::
  290. :: Create wbu_task.xml
  291. ::
  292. (
  293. echo ^<?xml version="1.0" encoding="UTF-16"?^>
  294. echo ^<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task"^>
  295. echo ^<RegistrationInfo^>
  296. echo ^<Date^>2018-02-18T08:29:39^</Date^>
  297. echo ^<Author^>pf100\rpo^</Author^>
  298. echo ^<URI^>\wub_task^</URI^>
  299. echo ^</RegistrationInfo^>
  300. echo ^<Triggers^>
  301. echo ^<BootTrigger^>
  302. echo ^<StartBoundary^>2018-02-18T08:29:00^</StartBoundary^>
  303. echo ^<Enabled^>true^</Enabled^>
  304. echo ^</BootTrigger^>
  305. echo ^</Triggers^>
  306. echo ^<Principals^>
  307. echo ^<Principal id="Author"^>
  308. echo ^<UserId^>S-1-5-18^</UserId^>
  309. echo ^<RunLevel^>HighestAvailable^</RunLevel^>
  310. echo ^</Principal^>
  311. echo ^</Principals^>
  312. echo ^<Settings^>
  313. echo ^<MultipleInstancesPolicy^>IgnoreNew^</MultipleInstancesPolicy^>
  314. echo ^<DisallowStartIfOnBatteries^>false^</DisallowStartIfOnBatteries^>
  315. echo ^<StopIfGoingOnBatteries^>false^</StopIfGoingOnBatteries^>
  316. echo ^<AllowHardTerminate^>true^</AllowHardTerminate^>
  317. echo ^<StartWhenAvailable^>false^</StartWhenAvailable^>
  318. echo ^<RunOnlyIfNetworkAvailable^>false^</RunOnlyIfNetworkAvailable^>
  319. echo ^<IdleSettings^>
  320. echo ^<StopOnIdleEnd^>true^</StopOnIdleEnd^>
  321. echo ^<RestartOnIdle^>false^</RestartOnIdle^>
  322. echo ^</IdleSettings^>
  323. echo ^<AllowStartOnDemand^>true^</AllowStartOnDemand^>
  324. echo ^<Enabled^>true^</Enabled^>
  325. echo ^<Hidden^>false^</Hidden^>
  326. echo ^<RunOnlyIfIdle^>false^</RunOnlyIfIdle^>
  327. echo ^<WakeToRun^>false^</WakeToRun^>
  328. echo ^<ExecutionTimeLimit^>PT72H^</ExecutionTimeLimit^>
  329. echo ^<Priority^>7^</Priority^>
  330. echo ^</Settings^>
  331. echo ^<Actions Context="Author"^>
  332. echo ^<Exec^>
  333. echo ^<Command^>"%~dp0wub.exe"^</Command^>
  334. echo ^<Arguments^>/d /p^</Arguments^>
  335. echo ^</Exec^>
  336. echo ^</Actions^>
  337. echo ^</Task^>
  338. )>"%~dp0%Task_Name%.xml"
  339. schtasks /delete /tn "%Task_Name%" /f 1>nul 2>nul
  340. schtasks /query /fo list 2>nul | findstr /i "%Task_Name%" 1>nul || (
  341. echo.&echo Creating Windows Update Blocker Auto-Renewal task %Task_Name%.
  342. schtasks /create /tn "%Task_Name%" /ru "SYSTEM" /xml "%~dp0%Task_Name%.xml" >nul 2>&1 || (
  343. echo.&Creating Windows Update Blocker Auto-Renewal %Task_Name% task errored.& echo Press any key to exit... & pause > nul &exit)
  344. rem echo Windows Update Blocker Auto-Renewal %Task_Name% created.
  345. del /f /q "%~dp0%Task_Name%.xml" >nul 2>&1)
  346. exit /b
  347. ::
  348. ::
  349. :Install_wdu_task
  350. set "Task_Name=WDU"
  351. ::
  352. :: Create WDU.cmd
  353. ::
  354. (
  355. echo rem Don't run this file. It's for use by wrapper script.
  356. echo cd /d "%%~dp0"
  357. echo query ^| find /i "windefend" ^> nul ^& if errorlevel 1 ^(exit^)
  358. echo if not exist wub.exe-backup ^(wub.exe /e^)
  359. echo "%ProgramFiles%\Windows Defender\MpCmdRun.exe" -SignatureUpdate
  360. echo if not exist wub.exe-backup ^(wub.exe /d /p^)
  361. echo exit
  362. )> "%~dp0%Task_Name%.cmd"
  363. ::
  364. :: Create WDU.xml
  365. ::
  366. (
  367. echo ^<?xml version="1.0" encoding="UTF-16"?^>
  368. echo ^<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task"^>
  369. echo ^<RegistrationInfo^>
  370. echo ^<Date^>2018-02-18T08:29:39^</Date^>
  371. echo ^<Author^>pf100\rpo^</Author^>
  372. echo ^<URI^>WindowsDefenderUpdate^</URI^>
  373. echo ^</RegistrationInfo^>
  374. echo ^<Triggers^>
  375. echo ^<CalendarTrigger^>
  376. echo ^<StartBoundary^>2018-05-12T10:35:00.0^</StartBoundary^>
  377. echo ^<Enabled^>true^</Enabled^>
  378. echo ^<ScheduleByDay^>
  379. echo ^<DaysInterval^>1^</DaysInterval^>
  380. echo ^</ScheduleByDay^>
  381. echo ^</CalendarTrigger^>
  382. echo ^</Triggers^>
  383. echo ^<Principals^>
  384. echo ^<Principal id="Author"^>
  385. echo ^<UserId^>S-1-5-18^</UserId^>
  386. echo ^<RunLevel^>HighestAvailable^</RunLevel^>
  387. echo ^</Principal^>
  388. echo ^</Principals^>
  389. echo ^<Settings^>
  390. echo ^<MultipleInstancesPolicy^>IgnoreNew^</MultipleInstancesPolicy^>
  391. echo ^<DisallowStartIfOnBatteries^>false^</DisallowStartIfOnBatteries^>
  392. echo ^<StopIfGoingOnBatteries^>false^</StopIfGoingOnBatteries^>
  393. echo ^<AllowHardTerminate^>true^</AllowHardTerminate^>
  394. echo ^<StartWhenAvailable^>true^</StartWhenAvailable^>
  395. echo ^<RunOnlyIfNetworkAvailable^>true^</RunOnlyIfNetworkAvailable^>
  396. echo ^<IdleSettings^>
  397. echo ^<StopOnIdleEnd^>true^</StopOnIdleEnd^>
  398. echo ^<RestartOnIdle^>false^</RestartOnIdle^>
  399. echo ^</IdleSettings^>
  400. echo ^<AllowStartOnDemand^>true^</AllowStartOnDemand^>
  401. echo ^<Enabled^>true^</Enabled^>
  402. echo ^<Hidden^>false^</Hidden^>
  403. echo ^<RunOnlyIfIdle^>false^</RunOnlyIfIdle^>
  404. echo ^<WakeToRun^>false^</WakeToRun^>
  405. echo ^<ExecutionTimeLimit^>PT72H^</ExecutionTimeLimit^>
  406. echo ^<Priority^>7^</Priority^>
  407. echo ^</Settings^>
  408. echo ^<Actions Context="Author"^>
  409. echo ^<Exec^>
  410. echo ^<Command^>"%~dp0WDU.cmd"^</Command^>
  411. echo ^</Exec^>
  412. echo ^</Actions^>
  413. echo ^</Task^>
  414. ) >"%~dp0%Task_Name%.xml"
  415. rem
  416. rem Creating Windows Defender Update auto renewal task
  417. rem
  418. schtasks /delete /tn "%Task_Name%" /f 1>nul 2>nul
  419. schtasks /query /fo list 2>nul | findstr /i "%Task_Name%" 1>nul || (
  420. echo.&echo Creating Windows Defender Update task %Task_Name%.
  421. schtasks /create /tn "%Task_Name%" /ru "SYSTEM" /xml "%~dp0%Task_Name%.xml" >nul 2>&1 || (
  422. echo.&echo Creating Windows Defender Update %Task_Name% task errored.& echo Press any key to exit... & pause > nul &exit)
  423. rem echo Windows Defender Update task %Task_Name% created.
  424. del /f /q "%~dp0%Task_Name%.xml" >nul 2>&1)
  425. exit /b
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement