pf100

v2.5.4 WUMTWrapperScript

Oct 6th, 2018
407
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.93 KB | None | 0 0
  1. @echo off
  2. mode con cols=89 lines=34
  3. Title WUMT Wrapper Script 2.5.4
  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. PowerRun v1.3 is available here: https://www.sordum.org/9416/powerrun-v1-3-run-with-highest-privileges/
  26. *******************************************************************
  27. How it works: The script first checks if the OS is Windows 8.1 or older and if so
  28. it notifies the user, then exits. Windows 10 only!
  29. This script creates a smart Windows Defender Update task "WDU" that updates Windows
  30. Defender every 2 hours if it's running and enabled, and doesn't update it if it's not
  31. running and disabled, saving resources; auto-elevates, uninstalls and removes the
  32. Windows 10 Update Assistant, disables everything in the %programfiles%\rempl folder, resets and
  33. removes permissions from and disables these Update Hijackers:
  34. remsh.exe
  35. osrss.dll
  36. UsoClient.exe
  37. WaaSMedic.exe
  38. WaasMedicSvc.dll
  39. WaaSMedicPS.dll
  40. WaaSAssessment.dll
  41. MusNotification.exe
  42. MusNotificationUx.exe
  43. SIHClient.exe
  44. disables all WindowsUpdate tasks except for "Automatic App Update" task which can only run
  45. if the windows update service is enabled with the Configurator.
  46. makes sure the task "wub_task" is installed that runs wub at boot (to stop updates from turning
  47. updates back on), runs wub.exe and enables and starts the windows update service (wuauserv) if
  48. disabled, installs "WDU" Windows Defender Update task that runs every 2 hours (but doesn't update
  49. Defender if Defender is disabled), then runs the correct version of the Windows Update MiniTool in
  50. "auto search for updates" mode for your OS version's architecture (x86 or x64), then disables and
  51. stops wuauserv giving you full control. No more forced automatic updates or surprise reboots.
  52. This was written for Windows 10 Pro and Home, but works with all versions of Windows 10. Don't
  53. change any settings in lower left of WUMT while running the script.
  54. *******************************************************************
  55. I also included an uninstaller.cmd that deletes the "WDU" and "wub_task" tasks, deletes the WDU.cmd
  56. file used by WDU task, restores the rempl folder, resets Update Hijacker permissions to how they
  57. were originally, renables "WindowsUpdate" tasks, and turns off wub (if enabled) which turns the windows update service on automatic
  58. again, undoing everything done by the script. If you uninstall after having used the installer the
  59. script files are removed also.
  60. *******************************************************************
  61. Configurator leaves the Update Hijackers disabled, but gives you the option of turning on the windows
  62. update service temporarily to use the Store or any other operation that requires the windows update
  63. service, such as some DISM operations, installing dotNet 3.5, App Updates, etc.
  64. *******************************************************************
  65. :start
  66. cd /d "%~dp0"
  67. :::::::::::::::::::::::::::::::::::::::::
  68. :: Automatically check & get admin rights
  69. :::::::::::::::::::::::::::::::::::::::::
  70. :: ECHO.
  71. :: ECHO =============================
  72. :: ECHO Running Admin shell
  73. :: ECHO =============================
  74. :: Check Privileges
  75. :: Get Privileges
  76. :: and
  77. :: Invoke UAC for Privilege Escalation
  78. :: Notify if error escalating
  79. :: and prevent looping if escalation fails
  80. ::::::::::::::::::::::::::::
  81. set "params=Problem_with_elevating_UAC_for_Administrator_Privileges"&if exist "%temp%\getadmin.vbs" del "%temp%\getadmin.vbs"
  82. fsutil dirty query %systemdrive% >nul 2>&1 && goto :GotPrivileges
  83. :: The following test is to avoid infinite looping if elevating UAC for Administrator Privileges failed
  84. 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)
  85. cmd /u /c echo Set UAC = CreateObject^("Shell.Application"^) : UAC.ShellExecute "%~0", "%params%", "", "runas", 1 > "%temp%\getadmin.vbs"&cscript //nologo "%temp%\getadmin.vbs"&exit
  86. :GotPrivileges
  87. ::::::::::::::::::::::::::::
  88. ::Uninstall and remove Windows 10 Update assistant.
  89. ::Disable Windows Update Service until script menu screen.
  90. ::Reset (in case of wrong Permissions), remove Permissions from and
  91. ::disable "Update Hijackers"
  92. ::Install wub_task (prevents Windows Update service from starting after installing updates and rebooting).
  93. ::Install "WDU" task that only updates Defender if it's enabled. Otherwise it doesn't do anything.
  94. ::Enable and start the Windows Update Service (wuauserv).
  95. ::Run the correct version of WUMT for your architecture.
  96. ::Start WUMT in "auto-check for updates" mode.
  97. ::After updates are completed and WUMT is closed and/or the "reboot"
  98. ::button in WUMT is pressed, silently run wub.exe and disable and stop wuauserv
  99. ::::::::::::::::::::::::::::
  100. @echo off
  101. cls
  102. ::Test for Windows versions below Windows 10 and if so inform user, then exit...
  103. ::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. if %winbuild% LEQ 9600 (
  108. cls
  109. echo.&echo This is not Windows 10. Press a key to exit...
  110. pause > nul
  111. exit
  112. )
  113. ::Remove Update Assistant
  114. if exist "%systemdrive%\Windows10Upgrade\Windows10UpgraderApp.exe" ( echo Windows 10 Update Assistant detected. Preparing to uninstall.
  115. echo The "Windows 10 Update Assistant has stopped working" dialog box may pop up. If so, just close it.
  116. echo Press a key to acknowledge this and please wait for the uninstall to finish.
  117. echo Script will continue after uninstall and removal is completed...
  118. pause > nul
  119. echo Uninstalling Windows 10 Update Assistant...
  120. %systemdrive%\Windows10Upgrade\Windows10UpgraderApp.exe /forceuninstall
  121. timeout /t 10 /nobreak)
  122. del %SystemDrive%\Windows10Upgrade\*.* /f /q >nul 2>&1
  123. rmdir %SystemDrive%\Windows10Upgrade /s /q >nul 2>&1
  124. del %systemroot%\UpdateAssistant\*.* /f /q >nul 2>&1
  125. rmdir %systemroot%\UpdateAssistant /s /q >nul 2>&1
  126. del %systemroot%\UpdateAssistantV2\*.* /f /q >nul 2>&1
  127. rmdir %systemroot%\UpdateAssistantV2 /s /q >nul 2>&1
  128. ::::::::::::::::::::::::::::
  129. echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.
  130. echo. & echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Initializing script...
  131. ::::::::::::::::::::::::::::
  132. if exist wub.exe-backup ren wub.exe-backup wub.exe
  133. ::::::::::::::::::::::::::::
  134. :: Disable all Language Components Installer tasks
  135. takeown /f "%systemroot%\System32\Tasks\Microsoft\Windows\LanguageComponentsInstaller\*" /a >nul 2>&1
  136. icacls "%systemroot%\System32\Tasks\Microsoft\Windows\LanguageComponentsInstaller\*" /q /c /t /reset >nul 2>&1
  137. for %%? in ("%systemroot%\System32\Tasks\Microsoft\Windows\LanguageComponentsInstaller\*") do schtasks /change /tn "Microsoft\Windows\LanguageComponentsInstaller\%%~nx?" /disable >nul 2>&1
  138. ::::::::::::::::::::::::::::
  139. :: Disable and lock all Windows Update tasks.
  140. takeown /f "%systemroot%\System32\Tasks\Microsoft\Windows\WindowsUpdate\*" /a >nul 2>&1
  141. icacls "%systemroot%\System32\Tasks\Microsoft\Windows\WindowsUpdate\*" /q /c /t /reset >nul 2>&1
  142. for %%? in ("%systemroot%\System32\Tasks\Microsoft\Windows\WindowsUpdate\*") do schtasks /change /tn "Microsoft\Windows\WindowsUpdate\%%~nx?" /disable >nul 2>&1
  143. 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
  144. ::::::::::::::::::::::::::::
  145. ::Set list (s32list) of update hijacker files to be disabled, then disable everything in the list.
  146. if exist PowerRun.ini del PowerRun.ini /f /q >nul 2>&1
  147. wmic cpu get AddressWidth /value|find "32">nul&&set prun=PowerRun.exe||set prun=PowerRun_x64.exe
  148. set s32list=EOSNotify.exe WaaSMedic.exe WaasMedicSvc.dll WaaSMedicPS.dll WaaSAssessment.dll UsoClient.exe
  149. set s32list=%s32list% SIHClient.exe MusNotificationUx.exe MusNotification.exe osrss.dll
  150. set s32=%systemroot%\System32
  151. for %%# in (%s32list%) do (
  152. takeown /f "%s32%\%%#" /a >nul 2>&1
  153. icacls "%s32%\%%#" /reset >nul 2>&1
  154. if exist "%s32%\%%#" "%prun%" /SW:0 "%systemroot%\System32\icacls.exe" "%s32%\%%#" /inheritance:r /remove *S-1-5-32-544 *S-1-5-11 *S-1-5-32-545 *S-1-5-18 >nul 2>&1
  155. )
  156. timeout /t 2 >nul 2>&1
  157. ::If files in "s32list" aren't locked for whatever reason, rename them.
  158. for %%# in (%s32list%) do (
  159. ren "%s32%\%%#" "%%#"-backup >nul 2>&1
  160. if exist "%s32%\%%#"-backup del "%s32%\%%#" /f /q >nul 2>&1
  161. )
  162. ::::::::::::::::::::::::::::
  163. ::Disable rempl
  164. for %%? in ("%ProgramFiles%\rempl\*") do (
  165. takeown /f "%%?" /a >nul 2>&1
  166. icacls "%%?" /reset >nul 2>&1
  167. 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
  168. )
  169. ::::::::::::::::::::::::::::
  170. cls
  171. echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.
  172. echo. & echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Initializing script...
  173. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Creating Tasks...
  174. ::::::::::::::::::::::::::::
  175. :: Create WDU.cmd
  176. (
  177. echo SETLOCAL EnableDelayedExpansion
  178. echo ::Allow only WDU task to run this file::
  179. echo whoami /user /nh ^| find /i "S-1-5-18" ^|^| exit
  180. echo cd /d "%%~dp0"
  181. echo ::Wait 5 minutes to prevent resource hogging after reboot with missed update::
  182. echo timeout /t 300
  183. echo ::If WUMT or WuMgr are running, cancel Defender update and exit. If not, continue::
  184. echo tasklist ^| findstr /irc:"wumt_x.*exe"
  185. echo if %%errorlevel%% equ 0 goto skipdefenderupdate
  186. echo tasklist ^| findstr "wumgr.exe"
  187. echo if %%errorlevel%% equ 0 goto skipdefenderupdate
  188. echo ::If Windows Defender is running, update it. If not, cancel Defender update and exit::
  189. echo sc query ^| find /i "windefend"
  190. echo if %%errorlevel%% equ 1 goto skipdefenderupdate
  191. echo ::Enable Windows Update service and update Defender, then disable Update Service::
  192. echo if not exist wub.exe-backup ^(wub.exe /e^)
  193. echo timeout /t 10
  194. echo "%%ProgramFiles%%\Windows Defender\MpCmdRun.exe" -SignatureUpdate
  195. echo if not exist wub.exe-backup ^(wub.exe /d /p^)
  196. echo goto defenderupdated
  197. echo :skipdefenderupdate
  198. echo set errorlevel=1
  199. echo :defenderupdated
  200. echo exit /b %%errorlevel%%
  201. )>wdu.cmd"
  202. ::::::::::::::::::::::::::::
  203. ::Create WDU task, and wub_task
  204. call :createwdu
  205. call :createwub_task
  206. ::::::::::::::::::::::::::::
  207. cls
  208. echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.
  209. echo. & echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Initializing script...
  210. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Creating Tasks...
  211. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Disabling update service...
  212. ::::::::::::::::::::::::::::
  213. ::Disable update service.
  214. wub.exe /d /p >nul 2>&1
  215. timeout /t 2 >nul 2>&1
  216. ::::::::::::::::::::::::::::
  217. :splash
  218. cls
  219. echo.
  220. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ::::::::::::::::::::::::::::::::
  221. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ : ^ Welcome to manual updates! ^ :
  222. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ::::::::::::::::::::::::::::::::
  223. echo.
  224. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ The Windows Update Service is now DISABLED and stopped.
  225. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ The tasks "WDU" and "wub_task" have been (re)created.
  226. echo.
  227. echo ^ * ^ After an update, you must re-run the script and just close this screen to make
  228. echo sure the "Update Hijackers" stay off. You may close this screen now.
  229. echo.
  230. echo ^ * ^ Automatic updates and "update hijackers" are now turned off. This script controls
  231. echo the update process. It automatically disables a range of "Update Hijackers" (see readme).
  232. echo.
  233. echo ^ * ^ If you choose to review any available Windows updates, it enables and starts only
  234. echo the Windows Update Service, then runs the Windows Update MiniTool (WUMT) to find and
  235. echo then hide or install selected Windows updates. Don't change WUMT settings while running
  236. echo this script. If WUMT is offering updates, you need to hide or install them before
  237. echo closing WUMT or it may install them later without asking next time.
  238. echo.
  239. echo ^ * ^ After checking for updates, the script stops and disables the Windows Update service
  240. echo when WUMT is closed regardless of whether the service was previously enabled.
  241. echo.
  242. echo ^ * ^ If you choose to use the Store, you can enable update service in Configurator.
  243. echo After using the Store, then either 1) disable update service or 2) continue script to
  244. echo check for Windows updates with WUMT after which the update service will be disabled.
  245. echo.
  246. echo ^ * ^ If you move this script to another folder run it again so the tasks will work!
  247. echo.
  248. echo ^ * ^ The included uninstaller undoes script changes.
  249. echo.&echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ---^>^>^> Press any key to continue. ^<^<^<---
  250. pause > nul
  251. ::::::::::::::::::::::::::::
  252. ::Windows Update Service Configurator
  253. cls
  254. echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.
  255. echo. & echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Initializing Configurator...
  256. ::disable windows update service except when wumt is run.
  257. :wudisable
  258. wub.exe /d /p >nul 2>&1
  259. timeout /t 2 /nobreak >nul 2>&1
  260. cls
  261. echo.&echo.
  262. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  263. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ :^ WUMT Wrapper Script Windows Update Service Configurator^ :
  264. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: &echo.&echo.
  265. echo.&echo.&echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ---^>^>^> Windows Update Service is DISABLED and stopped ^(default^) ^<^<^<---
  266. echo.&echo.&echo.&echo.&echo [E]nable Update Service temporarily to use Windows Store.
  267. echo.& echo [C]ontinue script to run WUMT and check for Windows Updates.
  268. echo ^ ^ ^ The Windows Update service will be automatically started and stopped.
  269. echo.& echo [Q]uit script, or "Alt + F4", or close window, if you're just verifying or are
  270. echo ^ ^ ^ finished changing the update service setting. It stays how it's set above.
  271. echo.&echo.&echo.&echo.&echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Please select [E], [C], or [Q] (or close window)
  272. echo.&echo.&echo.&echo.&echo.&echo.&echo.
  273. CHOICE /C ECQ /M "Your choice?:" >nul 2>&1
  274. if %errorlevel%==3 (exit)
  275. if %errorlevel%==2 (goto StartWUMT)
  276. cls
  277. echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.
  278. echo.&echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Please wait while Windows Update Service is enabled...
  279. ::enable windows update service
  280. :wuenable
  281. wub.exe /e >nul 2>&1
  282. timeout /t 2 /nobreak >nul 2>&1
  283. cls
  284. echo.&echo.&echo.
  285. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  286. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ :^ WUMT Wrapper Script Windows Update Service Configurator^ :
  287. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: &echo.&echo.&echo.
  288. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ---^>^>^> Windows Update Service is ENABLED ^(for Store^) ^<^<^<---
  289. echo.&echo.&echo.&echo [D]isable Update Service and only allow to run during script updates (default).
  290. echo.&echo [C]ontinue script to run WUMT and check for Windows Updates. Update service will
  291. echo ^ ^ ^ ^ ^ ^ be disabled automatically after update check and WUMT is closed.
  292. echo.&echo.&echo.&echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Please select [D] or [C]
  293. echo.&echo.&echo.&echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  294. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ :^ Don't close this window or update service will stay on!!!^ :
  295. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ : ^ ^ Don't worry. Just run the script again to turn it off ^ ^ :
  296. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  297. echo.&echo.&echo.&echo.
  298. CHOICE /C DC /M "Your choice?:" >nul 2>&1
  299. if %errorlevel%==2 (goto StartWUMT)
  300. if %errorlevel%==1 (
  301. cls
  302. echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.
  303. echo.&echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Please wait while Windows Update Service is disabled...
  304. goto wudisable
  305. )
  306. ::::::::::::::::::::::::::::
  307. :createwdu
  308. :: Create automatic Windows Defender Update "WDU" task that updates Defender only if it's enabled and running.
  309. set "Task_Name=WDU"
  310. :: Create WDU.xml
  311. ::
  312. set "w=echo f.writeline "
  313. (
  314. echo Set Fso=CreateObject^("Scripting.FileSystemObject"^):Set f=Fso.CreateTextFile^(fso.GetSpecialFolder^(2^) ^& "\task.xml",True^)
  315. %w%"<?xml version=""1.0"" encoding=""UTF-16""?>"
  316. %w%"<Task version=""1.2"" xmlns=""http://schemas.microsoft.com/windows/2004/02/mit/task"">"
  317. %w%"<RegistrationInfo>"
  318. %w%"<Date>2016-02-18T08:29:39</Date>"
  319. %w%"<Author>pf100\rpo</Author>"
  320. %w%"<URI>\WDU</URI>"
  321. %w%"</RegistrationInfo>"
  322. %w%"<Triggers>"
  323. %w%"<CalendarTrigger>"
  324. %w%"<Repetition>"
  325. %w%"<Interval>PT6H</Interval>"
  326. %w%"<StopAtDurationEnd>false</StopAtDurationEnd>"
  327. %w%"</Repetition>"
  328. %w%"<StartBoundary>2016-05-12T00:01:00.0</StartBoundary>"
  329. %w%"<Enabled>true</Enabled>"
  330. %w%"<ScheduleByDay>"
  331. %w%"<DaysInterval>1</DaysInterval>"
  332. %w%"</ScheduleByDay>"
  333. %w%"</CalendarTrigger>"
  334. %w%"</Triggers>"
  335. %w%"<Principals>"
  336. %w%"<Principal id=""Author"">"
  337. %w%"<RunLevel>HighestAvailable</RunLevel>"
  338. %w%"</Principal>"
  339. %w%"</Principals>"
  340. %w%"<Settings>"
  341. %w%"<MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>"
  342. %w%"<DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>"
  343. %w%"<StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>"
  344. %w%"<AllowHardTerminate>true</AllowHardTerminate>"
  345. %w%"<StartWhenAvailable>true</StartWhenAvailable>"
  346. %w%"<RunOnlyIfNetworkAvailable>true</RunOnlyIfNetworkAvailable>"
  347. %w%"<IdleSettings>"
  348. %w%"<StopOnIdleEnd>false</StopOnIdleEnd>"
  349. %w%"<RestartOnIdle>false</RestartOnIdle>"
  350. %w%"</IdleSettings>"
  351. %w%"<AllowStartOnDemand>true</AllowStartOnDemand>"
  352. %w%"<Enabled>true</Enabled>"
  353. %w%"<Hidden>false</Hidden>"
  354. %w%"<RunOnlyIfIdle>false</RunOnlyIfIdle>"
  355. %w%"<WakeToRun>false</WakeToRun>"
  356. %w%"<ExecutionTimeLimit>PT72H</ExecutionTimeLimit>"
  357. %w%"<Priority>7</Priority>"
  358. %w%"</Settings>"
  359. %w%"<Actions Context=""Author"">"
  360. %w%"<Exec>"
  361. %w%"<Command>""" ^& FSO.GetParentFolderName^(Wscript.ScriptFullName^) ^& "\%Task_Name%.cmd" ^& """</Command>"
  362. %w%"</Exec>"
  363. %w%"</Actions>"
  364. %w%"</Task>"
  365. echo f.Close
  366. )>"%~dp0task.vbs" &"%~dp0task.vbs" & del "%~dp0task.vbs"
  367. ::
  368. :: Creating Windows Defender Update auto renewal task
  369. ::
  370. schtasks /delete /tn "%Task_Name%" /f >nul 2>&1
  371. schtasks /query /tn "%Task_Name%" >nul 2>&1 || (
  372. schtasks /create /tn "%Task_Name%" /ru "SYSTEM" /xml "%temp%\task.xml" >nul 2>&1) || (
  373. 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)
  374. del "%temp%\task.xml" >nul 2>&1)
  375. exit /b
  376. ::::::::::::::::::::::::::::
  377. :createwub_task
  378. ::
  379. :: Create Windows Update Blocker "Wub_task" that sets your desired Windows Update service state at boot.
  380. ::
  381. :: Create Wub_task
  382. ::
  383. set "Task_Name=Wub_task"
  384. set "w=echo f.writeline "
  385. (
  386. echo Set Fso=CreateObject^("Scripting.FileSystemObject"^):Set f=Fso.CreateTextFile^(fso.GetSpecialFolder^(2^) ^& "\task.xml",True^)
  387. %w%"<?xml version=""1.0"" encoding=""UTF-16""?>"
  388. %w%"<Task version=""1.2"" xmlns=""http://schemas.microsoft.com/windows/2004/02/mit/task"">"
  389. %w%"<RegistrationInfo>"
  390. %w%"<Date>2016-02-18T08:29:39</Date>"
  391. %w%"<Author>pf100\rpo</Author>"
  392. %w%"<URI>\wub_task</URI>"
  393. %w%"</RegistrationInfo>"
  394. %w%"<Triggers>"
  395. %w%"<BootTrigger>"
  396. %w%"<StartBoundary>2016-02-18T08:29:00</StartBoundary>"
  397. %w%"<Enabled>true</Enabled>"
  398. %w%"</BootTrigger>"
  399. %w%"<LogonTrigger>"
  400. %w%"<Enabled>true</Enabled>"
  401. %w%"</LogonTrigger>"
  402. %w%"</Triggers>"
  403. %w%"<Principals>"
  404. %w%"<Principal id=""Author"">"
  405. %w%"<RunLevel>HighestAvailable</RunLevel>"
  406. %w%"</Principal>"
  407. %w%"</Principals>"
  408. %w%"<Settings>"
  409. %w%"<MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>"
  410. %w%"<DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>"
  411. %w%"<StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>"
  412. %w%"<AllowHardTerminate>true</AllowHardTerminate>"
  413. %w%"<StartWhenAvailable>true</StartWhenAvailable>"
  414. %w%"<RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>"
  415. %w%"<IdleSettings>"
  416. %w%"<StopOnIdleEnd>false</StopOnIdleEnd>"
  417. %w%"<RestartOnIdle>false</RestartOnIdle>"
  418. %w%"</IdleSettings>"
  419. %w%"<AllowStartOnDemand>true</AllowStartOnDemand>"
  420. %w%"<Enabled>true</Enabled>"
  421. %w%"<Hidden>false</Hidden>"
  422. %w%"<RunOnlyIfIdle>false</RunOnlyIfIdle>"
  423. %w%"<WakeToRun>false</WakeToRun>"
  424. %w%"<ExecutionTimeLimit>PT72H</ExecutionTimeLimit>"
  425. %w%"<Priority>7</Priority>"
  426. %w%"</Settings>"
  427. %w%"<Actions Context=""Author"">"
  428. %w%"<Exec>"
  429. %w%"<Command>""" ^& FSO.GetParentFolderName^(Wscript.ScriptFullName^) ^& "\Wub.exe""</Command>"
  430. %w%"<Arguments>/d /p</Arguments>"
  431. %w%"</Exec>"
  432. %w%"</Actions>"
  433. %w%"</Task>"
  434. echo f.Close
  435. )>"%~dp0task.vbs" & "%~dp0task.vbs" & del "%~dp0task.vbs"
  436. ::
  437. :: Creating Windows Update Blocker auto renewal task
  438. ::
  439. schtasks /delete /tn "%Task_Name%" /f >nul 2>&1
  440. schtasks /query /tn "%Task_Name%" >nul 2>&1 || (
  441. schtasks /create /tn "%Task_Name%" /ru "SYSTEM" /xml "%temp%\task.xml" >nul 2>&1) || (
  442. 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)
  443. del "%temp%\task.xml" >nul 2>&1)
  444. exit /b
  445. ::::::::::::::::::::::::::::
  446. :StartWUMT
  447. cls
  448. (
  449. echo @echo off
  450. echo :loop
  451. echo net start wuauserv
  452. echo timeout /t 10
  453. echo goto loop
  454. )>WU-keep-alive.cmd
  455. (
  456. echo @echo off
  457. echo cd /d "%%~dp0"
  458. echo del WU-keep-alive.cmd
  459. echo wub.exe /d /p
  460. echo del close.cmd ^& exit
  461. )>close.cmd
  462. wub.exe /e >nul 2>&1
  463. Start "" "%prun%" /SW:0 /SYS WU-keep-alive.cmd
  464. :: Check OS and run correct version of WUMT
  465. wmic cpu get AddressWidth /value|find "32">nul&&set wumt=wumt_x86.exe||set wumt=wumt_x64.exe
  466. Start "" "%wumt%" -update "-onclose close.cmd"
  467. ::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.
  468. rem Start "" wumgr.exe -update -online 7971f918-a847-4430-9279-4a52d1efe18d -onclose close.cmd
  469. exit
Advertisement
Add Comment
Please, Sign In to add comment