pf100

v2.5.2 WUMTWrapperScript.cmd

Aug 26th, 2018
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.65 KB | None | 0 0
  1. @echo off
  2. mode con cols=85 lines=13
  3. Title WUMT Wrapper Script 2.5.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 every 2 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. 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. rem Get Windows OS build number
  102. for /f "tokens=2 delims==" %%a in ('wmic path Win32_OperatingSystem get BuildNumber /value') do (
  103. set /a WinBuild=%%a
  104. )
  105. rem Test for Windows versions below Windows 10 and if so just install wub_task and start wumt.
  106. if %winbuild% LEQ 9600 (
  107. rem If somehow both files "wub.exe" and "wub.exe-backup" exist, delete "wub.exe-backup"
  108. rem If only wub.exe-backup exists, rename it to wub.exe
  109. rem (if exist "%~dp0wub.exe" (del "%~dp0wub.exe-backup" /f /q) else (ren "%~dp0wub.exe-backup" wub.exe))
  110. rem
  111. rem call :Install_wub_task
  112. goto :StartWUMT
  113. )
  114. ::Remove Update Assistant
  115. if exist "%systemdrive%\Windows10Upgrade\Windows10UpgraderApp.exe" ( echo Windows 10 Update Assistant detected. Preparing to uninstall.
  116. echo The "Windows 10 Update Assistant has stopped working" dialog box may pop up. If so, just close it.
  117. echo Press a key to acknowledge this and please wait for the uninstall to finish.
  118. echo Script will continue after uninstall and removal is completed...
  119. pause > nul
  120. echo Uninstalling Windows 10 Update Assistant...
  121. %systemdrive%\Windows10Upgrade\Windows10UpgraderApp.exe /forceuninstall
  122. timeout /t 10 /nobreak
  123. del %systemroot%\UpdateAssistant\*.* /f /q
  124. rmdir %systemroot%\UpdateAssistant /s /q
  125. del %SystemDrive%\Windows10Upgrade\*.* /f /q
  126. rmdir %SystemDrive%\Windows10Upgrade /s /q
  127. cls
  128. echo Windows 10 Update Assistant removed.
  129. echo Press a key to continue...
  130. pause > nul )
  131. del %systemroot%\UpdateAssistantV2\*.* /f /q >nul 2>&1
  132. rmdir %systemroot%\UpdateAssistantV2 /s /q >nul 2>&1
  133. ::::::::::::::::::::::::::::
  134. echo. & echo. & echo. & echo.
  135. echo. & echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Initializing script...
  136. ::::::::::::::::::::::::::::
  137. ::In case new script is copied over old script while wub.exe-backup exists, then wub.exe would exist too,
  138. ::so check if windows update service is disabled or not and then correctly delete either wub.exe or wub.exe-backup.
  139. Reg query "HKLM\SYSTEM\CurrentControlSet\Services\wuauserv" /v "Start" | find "4" >nul 2>&1
  140. 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)
  141. ::::::::::::::::::::::::::::
  142. :: Disable and lock all Windows Update tasks except for "Automatic App Update" and prevent them from being enabled.
  143. takeown /f "%systemroot%\System32\Tasks\Microsoft\Windows\WindowsUpdate\*" /a >nul 2>&1
  144. icacls "%systemroot%\System32\Tasks\Microsoft\Windows\WindowsUpdate\*" /q /c /t /reset >nul 2>&1
  145. for %%? in ("%systemroot%\System32\Tasks\Microsoft\Windows\WindowsUpdate\*") do schtasks /change /tn "Microsoft\Windows\WindowsUpdate\%%~nx?" /disable >nul 2>&1
  146. schtasks /change /tn "\Microsoft\Windows\WindowsUpdate\Automatic App Update" /enable >nul 2>&1
  147. 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
  148. icacls "%systemroot%\System32\Tasks\Microsoft\Windows\WindowsUpdate\Automatic App Update" /reset >nul 2>&1
  149. icacls "%systemroot%\System32\Tasks\Microsoft\Windows\WindowsUpdate\Automatic App Update" /setowner *S-1-5-18 >nul 2>&1
  150. ::::::::::::::::::::::::::::
  151. ::Set list (s32list) of update hijacker files to be disabled, then disable everything in the list.
  152. set s32list=EOSNotify.exe WaaSMedic.exe WaasMedicSvc.dll WaaSMedicPS.dll WaaSAssessment.dll UsoClient.exe
  153. set s32list=%s32list% SIHClient.exe MusNotificationUx.exe MusNotification.exe osrss.dll
  154. set s32=%systemroot%\System32
  155. for %%# in (%s32list%) do (
  156. takeown /f "%s32%\%%#" /a >nul 2>&1
  157. icacls "%s32%\%%#" /reset >nul 2>&1
  158. 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
  159. )
  160. ::::::::::::::::::::::::::::
  161. ::Disable update service unless overriden with Configurator in which case this command does nothing.
  162. "%~dp0wub.exe" /d /p >nul 2>&1
  163. ::::::::::::::::::::::::::::
  164. ::Disable rempl
  165. for %%? in ("%ProgramFiles%\rempl\*") do (
  166. takeown /f "%%?" /a >nul 2>&1
  167. icacls "%%?" /reset >nul 2>&1
  168. 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
  169. )
  170. ::::::::::::::::::::::::::::
  171. ::Windows Update Service Configurator
  172. cls
  173. echo. & echo. & echo. & echo.
  174. echo. & echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Initializing Configurator...
  175. Reg query "HKLM\SYSTEM\CurrentControlSet\Services\wuauserv" /v "Start" | find "4" >nul 2>&1
  176. if %errorlevel% == 1 goto wuenable
  177. ::disable windows update service except when wumt is run.
  178. :wudisable
  179. ren "%~dp0wub.exe-backup" wub.exe >nul 2>&1
  180. timeout /t 2 /nobreak >nul 2>&1
  181. "%~dp0wub.exe" /d /p >nul 2>&1
  182. timeout /t 2 /nobreak >nul 2>&1
  183. cls
  184. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ WUMT Wrapper Script Windows Update Service Configurator & echo.
  185. echo ^ ^ ^ ^ ^ ^ ---^>^>^> Windows Update Service is DISABLED and stopped ^(default^) ^<^<^<---
  186. echo. & echo [E]nable Update Service to allow Windows Store.
  187. echo. & echo [C]ontinue script to run WUMT and check for Windows Updates.
  188. echo. & echo [Q]uit script, or "Alt + F4", or close window, if you're just verifying or are
  189. echo ^ ^ ^ finished changing the update service setting. It stays how it's set above.
  190. echo. & echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Please select [E], [C], or [Q] (or close window)
  191. CHOICE /C ECQ /M "Your choice?:" >nul 2>&1
  192. if %errorlevel%==3 (exit)
  193. if %errorlevel%==2 (goto splash)
  194. cls
  195. echo. & echo. & echo.
  196. echo. & echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Please wait while Windows Update Service is enabled.
  197. echo. & echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ This will take a few seconds...
  198. timeout /t 2 /nobreak >nul 2>&1
  199. ::enable windows update service
  200. :wuenable
  201. ren "%~dp0wub.exe-backup" wub.exe >nul 2>&1
  202. timeout /t 2 /nobreak >nul 2>&1
  203. "%~dp0wub.exe" /e >nul 2>&1
  204. timeout /t 2 /nobreak >nul 2>&1
  205. "%~dp0wub.exe" /e >nul 2>&1
  206. timeout /t 2 /nobreak >nul 2>&1
  207. ren "%~dp0wub.exe" wub.exe-backup >nul 2>&1
  208. timeout /t 2 /nobreak >nul 2>&1
  209. cls
  210. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ WUMT Wrapper Script Windows Update Service Configurator & echo.
  211. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ---^>^>^> Windows Update Service is ENABLED ^(for Store^) ^<^<^<---
  212. echo. & echo [D]isable Update Service and only allow to run during updates with script (default).
  213. echo. & echo [C]ontinue script to run WUMT and check for Windows Updates.
  214. echo. & echo [Q]uit script, or "Alt + F4", or close window, if you're just verifying or are
  215. echo ^ ^ ^ finished changing the update service setting. It stays how it's set above.
  216. echo. & echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Please select [D], [C], or [Q]
  217. CHOICE /C DCQ /M "Your choice?:" >nul 2>&1
  218. if %errorlevel%==3 (exit)
  219. if %errorlevel%==2 (goto splash)
  220. if %errorlevel%==1 (
  221. cls
  222. echo. & echo. & echo.
  223. echo. & echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Please wait while Windows Update Service is disabled.
  224. echo. & echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ This will take a few seconds...
  225. timeout /t 2 /nobreak >nul 2>&1
  226. goto wudisable
  227. )
  228. ::::::::::::::::::::::::::::
  229. :splash
  230. mode con cols=56 lines=36
  231. cls
  232. echo ********************************************************
  233. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Welcome to manual updates!
  234. echo. & echo ^ ^ ^ Run script again after you install updates at
  235. echo ^ ^ least until Configurator appears to kill any newly
  236. echo ^ ^ ^ ^ ^ ^ ^ ^ ^ installed update hijackers!
  237. echo. & echo Press any key to check for updates, or close this screen
  238. echo ^ ^ ^ ^ ^ ^ ^ to cancel and leave updates turned off
  239. echo ^ ^ ^ ^ ^ ^ ^ (unless overridden with configurator). & echo.
  240. echo ********************************************************
  241. echo Automatic updates are now turned off (unless overriden
  242. echo with Configurator). This script automates the update
  243. echo process. It automatically disables a range of "Update
  244. echo Hijackers" such as: osrss, rempl, Uso, WaaS, SIH, and
  245. echo Update Assistant. Enables and starts only the Windows
  246. echo Update Service, runs the Windows Update MiniTool (WUMT).
  247. echo After updates, stops and disables the Windows Update
  248. echo service (unless overriden with Configurator). The
  249. echo included uninstaller undoes script changes. Closing WUMT
  250. echo at any time disables updates again (unless overriden
  251. echo with Configurator); however, if WUMT is already offering
  252. echo updates, you need to hide them and/or install them
  253. echo one-by-one before closing WUMT or it may install them
  254. echo without asking next time. Don't change WUMT settings
  255. echo while running this script. If an update requires a
  256. echo reboot, re-run the script after the reboot and just
  257. echo close the first screen to make sure the "Update
  258. echo Hijackers" stay off. Enable update service in
  259. echo Configurator in script to use the Store at the risk of
  260. echo possible unwanted updates if you leave it on. Better to
  261. echo enable updates, use store, then disable updates. Use at
  262. echo your discretion.
  263. echo ********************************************************
  264. echo ^ ^ ^ ^ Press any key to run Windows Update MiniTool...
  265. pause > nul
  266. :StartWUMT
  267. ::::::::::::::::::::::::::::
  268. ::Create automatic Windows Defender Update "WDU" task that updates Defender only if it's enabled and running.
  269. ::Create Windows Update Blocker "Wub_task" that sets your desired Windows Update service state at boot.
  270. pushd %~dp0
  271. cscript //nologo module.vbs >nul 2>&1
  272. cls
  273. popd
  274. ::::::::::::::::::::::::::::
  275. "%~dp0wub.exe" /e >nul 2>&1
  276. :: Check OS and run correct version of WUMT
  277. for /f "tokens=2 delims==" %%a in ('wmic cpu get AddressWidth /value') do (set arch=%%a)
  278. IF %arch% == 32 (set "wumt=%~dp0wumt_x86.exe") else (set "wumt=%~dp0wumt_x64.exe")
  279. Start "" "%wumt%" -update "-onclose %~dp0wub.exe /d /p"
  280. :EOF
Advertisement
Add Comment
Please, Sign In to add comment