Advertisement
pf100

v2.5.3 WUMTWrapperScript.cmd

Aug 29th, 2018
370
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.61 KB | None | 0 0
  1. @echo off
  2. mode con cols=89 lines=34
  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. 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. cls
  108. echo.&echo This is not Windows 10. Press a key to exit...
  109. pause > nul
  110. exit
  111. )
  112. ::Remove Update Assistant
  113. if exist "%systemdrive%\Windows10Upgrade\Windows10UpgraderApp.exe" ( echo Windows 10 Update Assistant detected. Preparing to uninstall.
  114. echo The "Windows 10 Update Assistant has stopped working" dialog box may pop up. If so, just close it.
  115. echo Press a key to acknowledge this and please wait for the uninstall to finish.
  116. echo Script will continue after uninstall and removal is completed...
  117. pause > nul
  118. echo Uninstalling Windows 10 Update Assistant...
  119. %systemdrive%\Windows10Upgrade\Windows10UpgraderApp.exe /forceuninstall
  120. timeout /t 10 /nobreak)
  121. del %SystemDrive%\Windows10Upgrade\*.* /f /q >nul 2>&1
  122. rmdir %SystemDrive%\Windows10Upgrade /s /q >nul 2>&1
  123. del %systemroot%\UpdateAssistant\*.* /f /q >nul 2>&1
  124. rmdir %systemroot%\UpdateAssistant /s /q >nul 2>&1
  125. del %systemroot%\UpdateAssistantV2\*.* /f /q >nul 2>&1
  126. rmdir %systemroot%\UpdateAssistantV2 /s /q >nul 2>&1
  127. ::::::::::::::::::::::::::::
  128. echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.
  129. echo. & echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Initializing script...
  130. ::::::::::::::::::::::::::::
  131. ::In case new script is copied over old script while wub.exe-backup exists, then wub.exe would exist too,
  132. ::so check if windows update service is disabled or not and then correctly delete either wub.exe or wub.exe-backup.
  133. Reg query "HKLM\SYSTEM\CurrentControlSet\Services\wuauserv" /v "Start" | find "4" >nul 2>&1
  134. if %errorlevel% == 0 (if exist wub.exe del wub.exe-backup /f /q >nul 2>&1) else (if exist wub.exe-backup del wub.exe /f /q >nul 2>&1)
  135. if exist wub.exe-backup ren wub.exe-backup wub.exe
  136. ::::::::::::::::::::::::::::
  137. :: Disable all Windows Update tasks.
  138. takeown /f "%systemroot%\System32\Tasks\Microsoft\Windows\WindowsUpdate\*" /a >nul 2>&1
  139. icacls "%systemroot%\System32\Tasks\Microsoft\Windows\WindowsUpdate\*" /q /c /t /reset >nul 2>&1
  140. for %%? in ("%systemroot%\System32\Tasks\Microsoft\Windows\WindowsUpdate\*") do schtasks /change /tn "Microsoft\Windows\WindowsUpdate\%%~nx?" /disable >nul 2>&1
  141. 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
  142. ::::::::::::::::::::::::::::
  143. ::Set list (s32list) of update hijacker files to be disabled, then disable everything in the list.
  144. set s32list=EOSNotify.exe WaaSMedic.exe WaasMedicSvc.dll WaaSMedicPS.dll WaaSAssessment.dll UsoClient.exe
  145. set s32list=%s32list% SIHClient.exe MusNotificationUx.exe MusNotification.exe osrss.dll
  146. set s32=%systemroot%\System32
  147. for %%# in (%s32list%) do (
  148. takeown /f "%s32%\%%#" /a >nul 2>&1
  149. icacls "%s32%\%%#" /reset >nul 2>&1
  150. 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
  151. )
  152. ::If files in "s32list" aren't locked for whatever reason, rename them.
  153. for %%# in (%s32list%) do (
  154. ren "%s32%\%%#" "%%#"-backup >nul 2>&1
  155. if exist "%s32%\%%#"-backup del "%s32%\%%#" /f /q >nul 2>&1
  156. )
  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. cls
  166. echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.
  167. echo. & echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Initializing script...
  168. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Creating Tasks...
  169. ::::::::::::::::::::::::::::
  170. :: Create WDU.cmd
  171. (
  172. echo SETLOCAL EnableDelayedExpansion
  173. echo ::Allow only WDU task to run this file::
  174. echo whoami /user /nh ^| find /i "S-1-5-18" ^|^| exit
  175. echo cd /d "%%~dp0"
  176. echo ::Wait 5 minutes to prevent resource hogging after reboot with missed update::
  177. echo timeout /t 300
  178. echo ::If WUMT or WuMgr are running, cancel Defender update and exit. If not, continue::
  179. echo tasklist ^| findstr /irc:"wumt_x.*exe"
  180. echo if %%errorlevel%% equ 0 goto skipdefenderupdate
  181. echo tasklist ^| findstr "wumgr.exe"
  182. echo if %%errorlevel%% equ 0 goto skipdefenderupdate
  183. echo ::If Windows Defender is running, update it. If not, cancel Defender update and exit::
  184. echo sc query ^| find /i "windefend"
  185. echo if %%errorlevel%% equ 1 goto skipdefenderupdate
  186. echo ::Enable Windows Update service and update Defender, then disable Update Service::
  187. echo if not exist wub.exe-backup ^(wub.exe /e^)
  188. echo timeout /t 10
  189. echo "%%ProgramFiles%%\Windows Defender\MpCmdRun.exe" -SignatureUpdate
  190. echo if not exist wub.exe-backup ^(wub.exe /d /p^)
  191. echo goto defenderupdated
  192. echo :skipdefenderupdate
  193. echo set errorlevel=1
  194. echo :defenderupdated
  195. echo exit /b %%errorlevel%%
  196. )>wdu.cmd"
  197. ::::::::::::::::::::::::::::
  198. ::Create WDU task, and wub_task
  199. call :createwdu
  200. call :createwub_task
  201. ::::::::::::::::::::::::::::
  202. cls
  203. echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.
  204. echo. & echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Initializing script...
  205. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Creating Tasks...
  206. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Disabling update service...
  207. ::::::::::::::::::::::::::::
  208. ::Disable update service.
  209. wub.exe /d /p >nul 2>&1
  210. timeout /t 2 >nul 2>&1
  211. ::::::::::::::::::::::::::::
  212. :splash
  213. cls
  214. echo.
  215. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ::::::::::::::::::::::::::::::::
  216. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ : ^ Welcome to manual updates! ^ :
  217. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ::::::::::::::::::::::::::::::::
  218. echo.
  219. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ The Windows Update Service is now DISABLED and stopped.
  220. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ The tasks "WDU" and "wub_task" have been (re)created.
  221. echo.
  222. echo ^ * ^ After an update, re-run the script and just close this screen to make sure the
  223. echo "Update Hijackers" stay off. You may close this screen now by clicking "X" in window.
  224. echo.
  225. echo ^ * ^ Automatic updates and "update hijackers" are now turned off. This script controls
  226. echo the update process. It automatically disables a range of "Update Hijackers" (see readme).
  227. echo.
  228. echo ^ * ^ If you choose to review any available Windows updates, it enables and starts only
  229. echo the Windows Update Service, then runs the Windows Update MiniTool (WUMT) to find and
  230. echo then hide or install selected Windows updates. Don't change WUMT settings while running
  231. echo this script. If WUMT is offering updates, you need to hide or install them before
  232. echo closing WUMT or it may install them later without asking next time.
  233. echo.
  234. echo ^ * ^ After checking for updates, the script stops and disables the Windows Update service
  235. echo when WUMT is closed regardless of whether the service was previously enabled.
  236. echo.
  237. echo ^ * ^ If you choose to use the Store, you can enable update service in Configurator.
  238. echo After using the Store, then either 1) disable update service or 2) continue script to
  239. echo check for Windows updates with WUMT after which the update service will be disabled.
  240. echo.
  241. echo ^ * ^ If you move this script to another folder run it again so the tasks will work!
  242. echo.
  243. echo ^ * ^ The included uninstaller undoes script changes.
  244. echo.&echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ---^>^>^> Press any key to continue. ^<^<^<---
  245. pause > nul
  246. ::::::::::::::::::::::::::::
  247. ::Windows Update Service Configurator
  248. cls
  249. echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.
  250. echo. & echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Initializing Configurator...
  251. ::disable windows update service except when wumt is run.
  252. :wudisable
  253. wub.exe /d /p >nul 2>&1
  254. timeout /t 2 /nobreak >nul 2>&1
  255. cls
  256. echo.&echo.
  257. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  258. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ :^ WUMT Wrapper Script Windows Update Service Configurator^ :
  259. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: &echo.&echo.
  260. echo.&echo.&echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ---^>^>^> Windows Update Service is DISABLED and stopped ^(default^) ^<^<^<---
  261. echo.&echo.&echo.&echo.&echo [E]nable Update Service temporarily to use Windows Store.
  262. echo.& echo [C]ontinue script to run WUMT and check for Windows Updates.
  263. echo.& echo [Q]uit script, or "Alt + F4", or close window, if you're just verifying or are
  264. echo ^ ^ ^ finished changing the update service setting. It stays how it's set above.
  265. echo.&echo.&echo.&echo.&echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Please select [E], [C], or [Q] (or close window)
  266. echo.&echo.&echo.&echo.&echo.&echo.&echo.
  267. CHOICE /C ECQ /M "Your choice?:" >nul 2>&1
  268. if %errorlevel%==3 (exit)
  269. if %errorlevel%==2 (goto StartWUMT)
  270. cls
  271. echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.
  272. echo.&echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Please wait while Windows Update Service is enabled...
  273. ::enable windows update service
  274. :wuenable
  275. wub.exe /e >nul 2>&1
  276. timeout /t 2 /nobreak >nul 2>&1
  277. cls
  278. echo.&echo.&echo.
  279. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  280. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ :^ WUMT Wrapper Script Windows Update Service Configurator^ :
  281. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: &echo.&echo.&echo.
  282. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ---^>^>^> Windows Update Service is ENABLED ^(for Store^) ^<^<^<---
  283. echo.&echo.&echo.&echo [D]isable Update Service and only allow to run during script updates (default).
  284. echo.&echo [C]ontinue script to run WUMT and check for Windows Updates. Update service will
  285. echo ^ ^ ^ ^ ^ ^ be disabled automatically after update check and WUMT is closed.
  286. echo.&echo.&echo.&echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Please select [D] or [C]
  287. echo.&echo.&echo.&echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  288. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ :^ Don't close this window or update service will stay on!!!^ :
  289. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ : ^ ^ Don't worry. Just run the script again to turn it off ^ ^ :
  290. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  291. echo.&echo.&echo.&echo.
  292. CHOICE /C DC /M "Your choice?:" >nul 2>&1
  293. if %errorlevel%==2 (goto StartWUMT)
  294. if %errorlevel%==1 (
  295. cls
  296. echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.
  297. echo.&echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Please wait while Windows Update Service is disabled...
  298. goto wudisable
  299. )
  300. ::::::::::::::::::::::::::::
  301. :createwdu
  302. :: Create automatic Windows Defender Update "WDU" task that updates Defender only if it's enabled and running.
  303. set "Task_Name=WDU"
  304. :: Create WDU.xml
  305. ::
  306. set "w=echo f.writeline "
  307. (
  308. echo Set Fso=CreateObject^("Scripting.FileSystemObject"^):Set f=Fso.CreateTextFile^(fso.GetSpecialFolder^(2^) ^& "\task.xml",True^)
  309. %w%"<?xml version=""1.0"" encoding=""UTF-16""?>"
  310. %w%"<Task version=""1.2"" xmlns=""http://schemas.microsoft.com/windows/2004/02/mit/task"">"
  311. %w%"<RegistrationInfo>"
  312. %w%"<Date>2016-02-18T08:29:39</Date>"
  313. %w%"<Author>pf100\rpo</Author>"
  314. %w%"<URI>\WDU</URI>"
  315. %w%"</RegistrationInfo>"
  316. %w%"<Triggers>"
  317. %w%"<CalendarTrigger>"
  318. %w%"<Repetition>"
  319. %w%"<Interval>PT6H</Interval>"
  320. %w%"<StopAtDurationEnd>false</StopAtDurationEnd>"
  321. %w%"</Repetition>"
  322. %w%"<StartBoundary>2016-05-12T00:01:00.0</StartBoundary>"
  323. %w%"<Enabled>true</Enabled>"
  324. %w%"<ScheduleByDay>"
  325. %w%"<DaysInterval>1</DaysInterval>"
  326. %w%"</ScheduleByDay>"
  327. %w%"</CalendarTrigger>"
  328. %w%"</Triggers>"
  329. %w%"<Principals>"
  330. %w%"<Principal id=""Author"">"
  331. %w%"<RunLevel>HighestAvailable</RunLevel>"
  332. %w%"</Principal>"
  333. %w%"</Principals>"
  334. %w%"<Settings>"
  335. %w%"<MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>"
  336. %w%"<DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>"
  337. %w%"<StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>"
  338. %w%"<AllowHardTerminate>true</AllowHardTerminate>"
  339. %w%"<StartWhenAvailable>true</StartWhenAvailable>"
  340. %w%"<RunOnlyIfNetworkAvailable>true</RunOnlyIfNetworkAvailable>"
  341. %w%"<IdleSettings>"
  342. %w%"<StopOnIdleEnd>false</StopOnIdleEnd>"
  343. %w%"<RestartOnIdle>false</RestartOnIdle>"
  344. %w%"</IdleSettings>"
  345. %w%"<AllowStartOnDemand>true</AllowStartOnDemand>"
  346. %w%"<Enabled>true</Enabled>"
  347. %w%"<Hidden>false</Hidden>"
  348. %w%"<RunOnlyIfIdle>false</RunOnlyIfIdle>"
  349. %w%"<WakeToRun>false</WakeToRun>"
  350. %w%"<ExecutionTimeLimit>PT72H</ExecutionTimeLimit>"
  351. %w%"<Priority>7</Priority>"
  352. %w%"</Settings>"
  353. %w%"<Actions Context=""Author"">"
  354. %w%"<Exec>"
  355. %w%"<Command>""" ^& FSO.GetParentFolderName^(Wscript.ScriptFullName^) ^& "\%Task_Name%.cmd" ^& """</Command>"
  356. %w%"</Exec>"
  357. %w%"</Actions>"
  358. %w%"</Task>"
  359. echo f.Close
  360. )>"%~dp0task.vbs" &"%~dp0task.vbs" & del "%~dp0task.vbs"
  361. ::
  362. :: Creating Windows Defender Update auto renewal task
  363. ::
  364. schtasks /delete /tn "%Task_Name%" /f >nul 2>&1
  365. schtasks /query /tn "%Task_Name%" >nul 2>&1 || (
  366. schtasks /create /tn "%Task_Name%" /ru "SYSTEM" /xml "%temp%\task.xml" >nul 2>&1) || (
  367. 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)
  368. del "%temp%\task.xml" >nul 2>&1)
  369. exit /b
  370. ::::::::::::::::::::::::::::
  371. :createwub_task
  372. ::
  373. :: Create Windows Update Blocker "Wub_task" that sets your desired Windows Update service state at boot.
  374. ::
  375. :: Create Wub_task
  376. ::
  377. set "Task_Name=Wub_task"
  378. set "w=echo f.writeline "
  379. (
  380. echo Set Fso=CreateObject^("Scripting.FileSystemObject"^):Set f=Fso.CreateTextFile^(fso.GetSpecialFolder^(2^) ^& "\task.xml",True^)
  381. %w%"<?xml version=""1.0"" encoding=""UTF-16""?>"
  382. %w%"<Task version=""1.2"" xmlns=""http://schemas.microsoft.com/windows/2004/02/mit/task"">"
  383. %w%"<RegistrationInfo>"
  384. %w%"<Date>2016-02-18T08:29:39</Date>"
  385. %w%"<Author>pf100\rpo</Author>"
  386. %w%"<URI>\wub_task</URI>"
  387. %w%"</RegistrationInfo>"
  388. %w%"<Triggers>"
  389. %w%"<BootTrigger>"
  390. %w%"<StartBoundary>2016-02-18T08:29:00</StartBoundary>"
  391. %w%"<Enabled>true</Enabled>"
  392. %w%"</BootTrigger>"
  393. %w%"<LogonTrigger>"
  394. %w%"<Enabled>true</Enabled>"
  395. %w%"</LogonTrigger>"
  396. %w%"</Triggers>"
  397. %w%"<Principals>"
  398. %w%"<Principal id=""Author"">"
  399. %w%"<RunLevel>HighestAvailable</RunLevel>"
  400. %w%"</Principal>"
  401. %w%"</Principals>"
  402. %w%"<Settings>"
  403. %w%"<MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>"
  404. %w%"<DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>"
  405. %w%"<StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>"
  406. %w%"<AllowHardTerminate>true</AllowHardTerminate>"
  407. %w%"<StartWhenAvailable>true</StartWhenAvailable>"
  408. %w%"<RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>"
  409. %w%"<IdleSettings>"
  410. %w%"<StopOnIdleEnd>false</StopOnIdleEnd>"
  411. %w%"<RestartOnIdle>false</RestartOnIdle>"
  412. %w%"</IdleSettings>"
  413. %w%"<AllowStartOnDemand>true</AllowStartOnDemand>"
  414. %w%"<Enabled>true</Enabled>"
  415. %w%"<Hidden>false</Hidden>"
  416. %w%"<RunOnlyIfIdle>false</RunOnlyIfIdle>"
  417. %w%"<WakeToRun>false</WakeToRun>"
  418. %w%"<ExecutionTimeLimit>PT72H</ExecutionTimeLimit>"
  419. %w%"<Priority>7</Priority>"
  420. %w%"</Settings>"
  421. %w%"<Actions Context=""Author"">"
  422. %w%"<Exec>"
  423. %w%"<Command>""" ^& FSO.GetParentFolderName^(Wscript.ScriptFullName^) ^& "\Wub.exe""</Command>"
  424. %w%"<Arguments>/d /p</Arguments>"
  425. %w%"</Exec>"
  426. %w%"</Actions>"
  427. %w%"</Task>"
  428. echo f.Close
  429. )>"%~dp0task.vbs" & "%~dp0task.vbs" & del "%~dp0task.vbs"
  430. ::
  431. :: Creating Windows Update Blocker auto renewal task
  432. ::
  433. schtasks /delete /tn "%Task_Name%" /f >nul 2>&1
  434. schtasks /query /tn "%Task_Name%" >nul 2>&1 || (
  435. schtasks /create /tn "%Task_Name%" /ru "SYSTEM" /xml "%temp%\task.xml" >nul 2>&1) || (
  436. 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)
  437. del "%temp%\task.xml" >nul 2>&1)
  438. exit /b
  439. ::::::::::::::::::::::::::::
  440. :StartWUMT
  441. cls
  442. (
  443. echo cd /d "%%~dp0"
  444. echo if exist wub.exe-backup ren wub.exe-backup wub.exe
  445. echo wub.exe /d /p
  446. echo del close.cmd ^& exit
  447. )>close.cmd
  448. wub.exe /e >nul 2>&1
  449. :: Check OS and run correct version of WUMT
  450. wmic cpu get AddressWidth /value|find "32">nul&&set wumt=wumt_x86.exe||set wumt=wumt_x64.exe
  451. Start "" "%wumt%" -update "-onclose close.cmd"
  452. ::If you want to use WuMgr instead of WUMT, insert rem (space) at beginning of WUMT line above, and un-rem the wumgr.exe line below.
  453. rem Start "" wumgr.exe -update -online 7971f918-a847-4430-9279-4a52d1efe18d -onclose close.cmd
  454. exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement