Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- mode con cols=89 lines=34
- Title Sledgehammer 2.6.0
- Color 1F & goto start
- Original script by pf100 @ MDL with special thanks to rpo and abbodi1406 @ MDL for code improvements.
- Project page and source code:
- https://forums.mydigitallife.net/threads/sledgehammer-windows-10-update-control.72203/
- ******************************************************************
- You may freely modify this script as you wish, I only request that you leave the credits and the
- link to the original script.
- ******************************************************************
- Don't move this script to another folder without running it again or the tasks won't work!
- This script provides manual updating for Windows 10 including Home versions.
- Update Windows 10 on your schedule, not Microsoft's!
- I originally wrote this script for personal use because of the lack of update options with the
- original RTM release of Windows 10 Pro. I wanted to update Windows 10 when I had the free time
- to manually update, just like I did with previous versions of Windows that allowed me to
- set updates to manual, not when Microsoft forced it on me while I was busy using my computer.
- *******************************************************************
- WUMT is available here: https://forums.mydigitallife.net/threads/64939-Windows-Update-MiniTool
- Windows Update Blocker is available here: http://sordum.org/files/windows-update-blocker/old/Wub_v1.0.zip
- Only use Windows Update Blocker v1.0 with this script, NOT v1.1!
- NSudo is available here: https://github.com/M2Team/NSudo/releases/tag/6.1
- *******************************************************************
- How it works: The script first checks if the OS is Windows 8.1 or older and if so
- it notifies the user, then exits. Windows 10 only!
- This script creates a smart Windows Defender Update task "WDU" that updates Windows
- Defender every 6 hours if it's running and enabled, and doesn't update it if it's not
- running and disabled, saving resources; auto-elevates, uninstalls and removes the
- Windows 10 Update Assistant, disables everything in the %programfiles%\rempl folder, resets and
- removes permissions from and disables these Update Hijackers:
- EOSNotify.exe
- WaaSMedic.exe
- WaasMedicSvc.dll
- WaaSMedicPS.dll
- WaaSAssessment.dll
- UsoClient.exe
- SIHClient.exe
- MusNotificationUx.exe
- MusNotification.exe
- osrss.dll
- %ProgramFiles%\rempl
- %systemroot%\UpdateAssistant
- %systemroot%\UpdateAssistantV2
- %systemdrive%\Windows10Upgrade
- disables all WindowsUpdate tasks
- makes sure the task "wub_task" is installed that runs wub at boot (to stop updates from turning
- updates back on), runs wub.exe and enables and starts the windows update service (wuauserv) if
- disabled, installs "WDU" Windows Defender Update task that runs every 2 hours (but doesn't update
- Defender if Defender is disabled), then runs the correct version of the Windows Update MiniTool in
- "auto search for updates" mode for your OS version's architecture (x86 or x64), then disables and
- stops wuauserv giving you full control. No more forced automatic updates or surprise reboots.
- This was written for Windows 10 Pro and Home, but works with all versions of Windows 10. Don't
- change any settings in lower left of WUMT while running the script.
- *******************************************************************
- I also included an uninstaller.cmd that deletes the "WDU" and "wub_task" tasks, deletes the WDU.cmd
- file used by WDU task, restores the rempl folder, resets Update Hijacker permissions to how they
- were originally, renables "WindowsUpdate" tasks, and turns off wub (if enabled) which turns the windows update service on automatic
- again, undoing everything done by the script. If you uninstall after having used the installer the
- script files are removed also.
- *******************************************************************
- Configurator leaves the Update Hijackers disabled, but gives you the option of turning on the windows
- update service temporarily to use the Store or any other operation that requires the windows update
- service, such as some DISM operations, installing dotNet 3.5, App Updates, etc.
- *******************************************************************
- :start
- cd /d "%~dp0"
- :::::::::::::::::::::::::::::::::::::::::
- :: Automatically check & get admin rights
- :::::::::::::::::::::::::::::::::::::::::
- :: ECHO.
- :: ECHO =============================
- :: ECHO Running Admin shell
- :: ECHO =============================
- :: Check Privileges
- :: Get Privileges
- :: and
- :: Invoke UAC for Privilege Escalation
- :: Notify if error escalating
- :: and prevent looping if escalation fails
- ::::::::::::::::::::::::::::
- set "params=Problem_with_elevating_UAC_for_Administrator_Privileges"&if exist "%temp%\getadmin.vbs" del "%temp%\getadmin.vbs"
- fsutil dirty query %systemdrive% >nul 2>&1 && goto :GotPrivileges
- :: The following test is to avoid infinite looping if elevating UAC for Administrator Privileges failed
- 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)
- cmd /u /c echo Set UAC = CreateObject^("Shell.Application"^) : UAC.ShellExecute "%~0", "%params%", "", "runas", 1 > "%temp%\getadmin.vbs"&cscript //nologo "%temp%\getadmin.vbs"&exit
- :GotPrivileges
- ::::::::::::::::::::::::::::
- ::Uninstall and remove Windows 10 Update assistant.
- ::Disable Windows Update Service until script menu screen.
- ::Reset (in case of wrong Permissions), remove Permissions from and
- ::disable "Update Hijackers"
- ::Install wub_task (prevents Windows Update service from starting after installing updates and rebooting).
- ::Install "WDU" task that only updates Defender if it's enabled. Otherwise it doesn't do anything.
- ::Enable and start the Windows Update Service (wuauserv).
- ::Run the correct version of WUMT for your architecture.
- ::Start WUMT in "auto-check for updates" mode.
- ::After updates are completed and WUMT is closed and/or the "reboot"
- ::button in WUMT is pressed, silently run wub.exe and disable and stop wuauserv
- ::::::::::::::::::::::::::::
- ::Test for Windows versions below Windows 10 and if so inform user, then exit...
- ::Get Windows OS build number
- for /f "tokens=2 delims==" %%a in ('wmic path Win32_OperatingSystem get BuildNumber /value') do (
- set /a WinBuild=%%a
- )
- if %winbuild% LEQ 9600 (
- echo.&echo This is not Windows 10. Press a key to exit...
- pause > nul
- exit
- )
- ::::::::::::::::::::::::::::
- ::Determine if running 32 or 64 bit Windows OS and set variables accordingly.
- wmic cpu get AddressWidth /value|find "32">nul&&set PROCESSOR_ARCHITECTURE=X86||set PROCESSOR_ARCHITECTURE=AMD64
- if %PROCESSOR_ARCHITECTURE%==AMD64 (
- set "nsudovar=.\bin\NSudoCx64.exe"
- set "wumt=.\bin\wumt_x64.exe"
- ) else (
- set "nsudovar=.\bin\NSudoc.exe"
- set "wumt=.\bin\wumt_x86.exe"
- )
- ::::::::::::::::::::::::::::
- ::Remove and/or lock Update Assistant
- if exist "%systemdrive%\Windows10Upgrade\Windows10UpgraderApp.exe" ( echo Windows 10 Update Assistant detected. Preparing to uninstall.
- echo The "Windows 10 Update Assistant has stopped working" dialog box may pop up.
- echo If so, just close it.
- echo.& echo Press a key to acknowledge this and please wait for the uninstall to finish.
- echo Script will continue after uninstall and removal is completed...
- pause > nul
- echo Uninstalling Windows 10 Update Assistant...
- %systemdrive%\Windows10Upgrade\Windows10UpgraderApp.exe /forceuninstall
- timeout /t 10 /nobreak
- cls)
- ::::::::::::::::::::::::::::
- (
- echo # Get MS-Defcon from askwoody.com
- echo $progressPreference = 'silentlyContinue'
- echo "`r`nAttempting to retrieve MS-DEFCON rating from askwoody.com...`r`n"
- echo Try {$WebResponse = Invoke-WebRequest "https://www.askwoody.com/" -UseBasicParsing} Catch {$WebResponse=""}
- echo clear-host
- echo if ^($WebResponse.Statuscode -ne 200^){write-host "Unable to retrieve MS-DEFCON rating from askwoody.com"; exit}
- echo ForEach ^($Image in $WebResponse.Images^) {
- echo $x = $Image.OuterHTML.ToString^(^)
- echo If ^($x -like "*MS-DEFCON-*"^) {
- echo "`r`nMS-DEFCON = " + $x.split^('/'^)[8].split^('.'^)[0].SubString^(10,1^)
- echo "`r`n::::::::::::::::::::::::::::"
- echo "`r`nMS-DEFCON 1: Current Microsoft patches are causing havoc. Don't patch.`r`n" + `
- echo "`r`nMS-DEFCON 2: Patch reliability is unclear. Unless you have an immediate, pressing need" + `
- echo "`r`n to install a specific patch, don't do it.`r`n" + `
- echo "`r`nMS-DEFCON 3: Patch reliability is unclear, but widespread attacks make patching prudent." + `
- echo "`r`n Go ahead and patch, but watch out for potential problems.`r`n" + `
- echo "`r`nMS-DEFCON 4: There are isolated problems with current patches, but they are well-known" + `
- echo "`r`n and documented here. Check this site to see if you're affected and if" + `
- echo "`r`n things look OK, go ahead and patch.`r`n" + `
- echo "`r`nMS-DEFCON 5: All's clear. Patch while it's safe.`r`n" + `
- echo "`r`nMore info at https://www.askwoody.com"
- echo exit
- echo }
- echo }
- )>"%temp%\awmsdc.ps1"
- PowerShell.exe -Nologo -NoProfile -ExecutionPolicy Bypass -command "%temp%\awmsdc.ps1"
- del "%temp%\awmsdc.ps1"
- ::::::::::::::::::::::::::::
- rem echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.
- echo.
- echo Disabling update hijackers...
- echo Creating tasks...
- echo Disabling windows Update Service...
- echo.
- ::::::::::::::::::::::::::::
- schtasks /delete /tn WDU >nul /f 2>&1
- schtasks /delete /tn Wub_task /f >nul 2>&1
- schtasks /Delete /Tn \Microsoft\WuWrapperScript\WDU /f >nul 2>&1
- schtasks /Delete /Tn \Microsoft\WuWrapperScript\Wub_task /f >nul 2>&1
- rmdir %SystemDrive%\Windows\System32\Tasks\Microsoft\WuWrapperScript /s /q >nul 2>&1
- %nsudovar% -ShowWindowMode:Hide -Wait -U:T -P:E reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Microsoft\WuWrapperScript" /f >nul 2>&1
- schtasks /Delete /Tn \Microsoft\Sledgehammer\WDU /f >nul 2>&1
- schtasks /Delete /Tn \Microsoft\Sledgehammer\Wub_task /f >nul 2>&1
- rmdir %SystemDrive%\Windows\System32\Tasks\Microsoft\Sledgehammer /s /q >nul 2>&1
- %nsudovar% -ShowWindowMode:Hide -Wait -U:T -P:E reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Microsoft\Sledgehammer" /f >nul 2>&1
- ::::::::::::::::::::::::::::::::::
- takeown /f "%systemroot%\UpdateAssistant" /a >nul 2>&1
- icacls "%systemroot%\UpdateAssistant" /reset >nul 2>&1
- del %systemroot%\UpdateAssistant\*.* /f /q >nul 2>&1
- rmdir %systemroot%\UpdateAssistant /s /q >nul 2>&1
- md "%systemroot%\UpdateAssistant" >nul 2>&1
- attrib +s +h "%systemroot%\UpdateAssistant" >nul 2>&1
- %nsudovar% -ShowWindowMode:Hide -Wait -U:T -P:E "%systemroot%\System32\icacls.exe" %systemroot%\UpdateAssistant /inheritance:r /remove:g *S-1-5-32-544 *S-1-5-11 *S-1-5-32-545 *S-1-5-18 >nul 2>&1
- takeown /f "%systemroot%\UpdateAssistantV2" /a >nul 2>&1
- icacls "%systemroot%\UpdateAssistantV2" /reset >nul 2>&1
- del %systemroot%\UpdateAssistantV2\*.* /f /q >nul 2>&1
- md "%systemroot%\UpdateAssistantV2" >nul 2>&1
- attrib +s +h "%systemroot%\UpdateAssistantV2" >nul 2>&1
- %nsudovar% -ShowWindowMode:Hide -Wait -U:T -P:E "%systemroot%\System32\icacls.exe" %systemroot%\UpdateAssistantV2 /inheritance:r /remove:g *S-1-5-32-544 *S-1-5-11 *S-1-5-32-545 *S-1-5-18 >nul 2>&1
- takeown /f "%SystemDrive%\Windows10Upgrade" /a >nul 2>&1
- icacls "%SystemDrive%\Windows10Upgrade" /reset >nul 2>&1
- del %SystemDrive%\Windows10Upgrade\*.* /f /q >nul 2>&1
- rmdir %SystemDrive%\Windows10Upgrade /s /q >nul 2>&1
- md "%systemdrive%\Windows10Upgrade" >nul 2>&1
- attrib +s +h %systemdrive%\Windows10Upgrade >nul 2>&1
- %nsudovar% -ShowWindowMode:Hide -Wait -U:T -P:E "%systemroot%\System32\icacls.exe" %systemdrive%\Windows10Upgrade /inheritance:r /remove:g *S-1-5-32-544 *S-1-5-11 *S-1-5-32-545 *S-1-5-18 >nul 2>&1
- ::::::::::::::::::::::::::::
- ::Disable rempl
- if not exist "%ProgramFiles%\rempl" goto norempl
- takeown /f "%ProgramFiles%\rempl" /a >nul 2>&1
- icacls "%ProgramFiles%\rempl" /reset >nul 2>&1
- for %%? in ("%ProgramFiles%\rempl\*") do (
- takeown /f "%%?" /a >nul 2>&1
- icacls "%%?" /reset >nul 2>&1
- )
- del %ProgramFiles%\rempl\*.* /f /q >nul 2>&1
- rmdir %ProgramFiles%\rempl /s /q >nul 2>&1
- :norempl
- ::The rempl folder doesn't exist, so create it and lock it from system access.
- md "%ProgramFiles%\rempl" >nul 2>&1
- attrib +s +h "%ProgramFiles%\rempl" >nul 2>&1
- %nsudovar% -ShowWindowMode:Hide -Wait -U:T -P:E "%systemroot%\System32\icacls.exe" "%ProgramFiles%\rempl" /inheritance:r /remove:g *S-1-5-32-544 *S-1-5-11 *S-1-5-32-545 *S-1-5-18 >nul 2>&1
- ::::::::::::::::::::::::::::
- :: Disable all Language Components Installer tasks
- takeown /f "%systemroot%\System32\Tasks\Microsoft\Windows\LanguageComponentsInstaller\*" /a >nul 2>&1
- icacls "%systemroot%\System32\Tasks\Microsoft\Windows\LanguageComponentsInstaller\*" /q /c /t /reset >nul 2>&1
- for %%? in ("%systemroot%\System32\Tasks\Microsoft\Windows\LanguageComponentsInstaller\*") do schtasks /change /tn "Microsoft\Windows\LanguageComponentsInstaller\%%~nx?" /disable >nul 2>&1
- ::::::::::::::::::::::::::::
- :: Disable and lock all Windows Update tasks.
- takeown /f "%systemroot%\System32\Tasks\Microsoft\Windows\WindowsUpdate\*" /a >nul 2>&1
- icacls "%systemroot%\System32\Tasks\Microsoft\Windows\WindowsUpdate\*" /q /c /t /reset >nul 2>&1
- for %%? in ("%systemroot%\System32\Tasks\Microsoft\Windows\WindowsUpdate\*") do schtasks /change /tn "Microsoft\Windows\WindowsUpdate\%%~nx?" /disable >nul 2>&1
- 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
- ::::::::::::::::::::::::::::
- ::Set list (s32list) of update hijacker files to be disabled, then disable everything in the list.
- set s32list=EOSNotify.exe WaaSMedic.exe WaasMedicSvc.dll WaaSMedicPS.dll WaaSAssessment.dll UsoClient.exe
- set s32list=%s32list% SIHClient.exe MusNotificationUx.exe MusNotification.exe osrss.dll
- set s32=%systemroot%\System32
- ::If "s32list" files were previously renamed by script, restore original file names
- for %%# in (%s32list%) do (
- ren "%s32%\%%#"-backup "%%#" >nul 2>&1
- if exist "%s32%\%%#" del "%s32%\%%#"-backup /f /q >nul 2>&1
- )
- ::Lock files
- for %%# in (%s32list%) do (
- takeown /f "%s32%\%%#" /a >nul 2>&1
- icacls "%s32%\%%#" /reset >nul 2>&1
- if exist "%s32%\%%#" %nsudovar% -ShowWindowMode:Hide -Wait -U:T -P:E "%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
- )
- ::If files in "s32list" aren't locked for whatever reason, rename them.
- for %%# in (%s32list%) do (
- ren "%s32%\%%#" "%%#"-backup >nul 2>&1
- if exist "%s32%\%%#"-backup del "%s32%\%%#" /f /q >nul 2>&1
- )
- ::::::::::::::::::::::::::::
- :: Create WDU.cmd
- (
- echo ::Allow only WDU task to run this file::
- echo whoami /user /nh ^| find /i "S-1-5-18" ^|^| exit
- echo cd /d "%%~dp0"
- echo ::Wait 5 minutes to prevent resource hogging after reboot with missed update::
- echo timeout /t 300^>nul
- echo ::If WUMT or WuMgr are running, cancel Defender update and exit. If not, continue::
- echo tasklist ^| findstr /i "wumt_x86.exe wumt_x64.exe wumgr.exe" ^&^& exit 1
- echo ::If Windows Defender is running, update it. If not, cancel Defender update and exit::
- echo sc query ^| find /i "windefend" ^|^| exit 1
- echo ::Enable Windows Update service and update Defender, then disable Update Service::
- echo wub.exe /e
- echo timeout /t 10
- echo "%%ProgramFiles%%\Windows Defender\MpCmdRun.exe" -SignatureUpdate
- echo wub.exe /d /p
- echo exit /b %%errorlevel%%
- )>.\bin\wdu.cmd"
- ::::::::::::::::::::::::::::
- ::Create WDU task, and wub_task
- call :create_task WDU "Windows Defender Update"
- call :create_task Wub_task "Windows Update Blocker Auto-Renewal"
- ::::::::::::::::::::::::::::
- ::Disable update service.
- call :wuauserv d
- ::::::::::::::::::::::::::::
- echo Windows 10 updates disabled.
- echo Close window ^(click "X"^) if done, or press a key to check for updates...
- pause >nul 2>&1
- :splash
- cls
- echo.
- echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ::::::::::::::::::::::::::::::::
- echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ : ^ Welcome to manual updates! ^ :
- echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ::::::::::::::::::::::::::::::::
- echo.
- echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ The Windows Update Service is now DISABLED and stopped.
- echo ^ ^ The tasks "WDU" (Windows Defender Update) and "wub_task" (Forces Update service off
- echo ^ ^ ^ ^ ^ ^ ^ ^ after reboot and login) have been (re)created.
- echo.
- echo ^ * ^ Update Hijackers are now disabled! (see readme for details)
- echo ^ * ^ If you just want to disable the Update Hijackers and not check for or install
- echo ^ ^ ^ ^ updates, you may close this screen now.
- echo.
- echo ^ * ^ If you choose to review any available Windows updates, the script enables and
- echo ^ ^ ^ ^ starts only the Windows Update Service, then runs the Windows update Manager
- echo ^ ^ ^ ^ (WuMgr) or the Windows Update MiniTool (WUMT) to find and then hide or install
- echo ^ ^ ^ ^ selected Windows updates. If you run WUMT, don't change WUMT settings while
- echo ^ ^ ^ ^ running this script. If WuMgr or WUMT is offering updates, you need to hide or
- echo ^ ^ ^ ^ install them before closing WuMgr or WUMT.
- echo.
- echo ^ * ^ After checking for updates, the script stops and disables the Windows Update service
- echo ^ ^ ^ ^ when WuMgr or WUMT is closed whether or not the service was previously enabled.
- echo.
- echo ^ * ^ If you choose to use the Store, you can enable update service in Configurator.
- echo ^ ^ ^ ^ After using the Store, then either 1) disable update service or 2) continue script to
- echo ^ ^ ^ ^ check for Windows updates with WuMgr or WUMT after which the update service will be
- echo ^ ^ ^ ^ disabled.
- echo.
- echo ^ * ^ If you move this script to another folder run it again so the tasks will work!
- echo.
- echo ^ * ^ The included uninstaller undoes script changes.
- echo.&echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ---^>^>^> Press any key to continue. ^<^<^<---
- pause > nul
- ::::::::::::::::::::::::::::
- ::Internet connection check
- cls
- echo Internet check.
- ping pool.ntp.org > nul
- cls
- if errorlevel 1 (echo.&echo Internet connection test failed. & echo ^(Tested with ping to pool.ntp.org. Please report if this IP is &echo unavailable in your area.^)&echo.&echo ---^>^>^> Press a key to continue if you're sure internet is working. ^<^<^<--- & echo.&echo It's safe to cancel now if needed. Your system will not be left in an unstable state.&echo ^(Ctrl-C, Alt-F4, or click "X" to cancel and exit^)) else (goto ContinePostInternetCheck)
- pause > nul
- :ContinePostInternetCheck
- ::::::::::::::::::::::::::::
- ::Windows Update Service Configurator
- cls
- echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.
- echo. & echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Initializing Configurator...
- ::disable windows update service except when wumt is run.
- :wudisable
- call :wuauserv d
- cls
- echo.&echo.&echo.
- echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ : ^Windows 10 Update Control Wrapper Script Service Configurator ^:
- echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- echo.&echo.&echo.
- echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ---^>^>^> Windows Update Service is DISABLED and stopped ^(default^) ^<^<^<---
- echo.&echo.&echo. ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ [E]nable Update Service temporarily to use Windows Store.
- echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ or
- echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ [1] Continue script to run Windows Update Manager (WuMgr)
- echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ and check for Windows Updates.
- echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ or
- echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ [2] Continue script to run Windows Update Minitool (WUMT)
- echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ and check for Windows Updates.
- echo.&
- echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ The Windows Update service will be automatically
- echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ started and stopped.
- echo.&
- echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ [Q]uit script, or "Alt + F4", or close window, if you're just
- echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ verifying or are finished changing the update service setting.
- echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ It stays how it's set above.
- echo.&echo.&echo.&echo.
- echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Please select [E], [1], [2], or [Q] (or close window)
- echo.&echo.&echo.
- CHOICE /C E12Q /M "Your choice?:" >nul 2>&1
- if %errorlevel%==4 (exit)
- if %errorlevel%==3 (goto :StartWUMT)
- if %errorlevel%==2 (set "WuMgr=Y"&goto :StartWUMT)
- cls
- echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.
- echo.&echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Please wait while Windows Update Service is enabled...
- ::enable windows update service
- :wuenable
- call :wuauserv e
- echo.&echo.
- echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ : ^Windows 10 Update Control Wrapper Script Service Configurator ^:
- echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: &echo.&echo.
- echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ---^>^>^> Windows Update Service is ENABLED ^(for Store^) ^<^<^<---
- echo.&echo.&echo. ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ [D]isable Update Service when finished using Store.
- echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ or
- echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ [1] Continue script to run Windows Update Manager (WuMgr)
- echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ and check for Windows Updates.
- echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ or
- echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ [2] Continue script to run Windows Update Minitool (WUMT)
- echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ and check for Windows Updates.
- echo.
- echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ *Update service will be disabled automatically after
- echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ update check and WUMT/WuMgr is closed.*
- echo.&echo.&echo.&echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Please select [D], [1], or [2]
- echo.&echo.&echo.&echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ :^ Don't close this window or update service will stay on!!!^ :
- echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ : ^ ^ Don't worry. Just run the script again to turn it off ^ ^ :
- echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- CHOICE /C D12 /M "Your choice?:" >nul 2>&1
- if %errorlevel%==3 (goto :StartWUMT)
- if %errorlevel%==2 (set "WuMgr=Y"&goto :StartWUMT)
- if %errorlevel%==1 (
- cls
- echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.
- echo.&echo ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Please wait while Windows Update Service is disabled...
- goto wudisable
- )
- ::::::::::::::::::::::::::::
- :create_task
- set "w=echo f.writeline "
- echo Set Fso=CreateObject^("Scripting.FileSystemObject"^):Set f=Fso.CreateTextFile^(fso.GetParentFolderName^(WScript.ScriptFullName^) ^& "\task.xml",True,True^)>task.vbs
- if /i %1==wdu (
- rem Create automatic Windows Defender Update "WDU" task that updates Defender only if it's enabled and running.
- rem Create WDU.xml
- rem
- rem
- rem Creating Windows Defender Update auto renewal task
- rem
- (
- %w%"<?xml version=""1.0"" encoding=""UTF-16""?>"
- %w%"<Task version=""1.2"" xmlns=""http://schemas.microsoft.com/windows/2004/02/mit/task"">"
- %w%"<RegistrationInfo>"
- %w%"<Date>2016-02-18T08:29:39</Date>"
- %w%"<Author>pf100\rpo</Author>"
- %w%"<URI>WindowsDefenderUpdate</URI>"
- %w%"</RegistrationInfo>"
- %w%"<Triggers>"
- %w%"<CalendarTrigger>"
- %w%"<StartBoundary>2016-01-01T00:01:00</StartBoundary>"
- %w%"<Enabled>true</Enabled>"
- %w%"<ScheduleByDay>"
- %w%"<DaysInterval>1</DaysInterval>"
- %w%"</ScheduleByDay>"
- %w%"</CalendarTrigger>"
- %w%"<CalendarTrigger>"
- %w%"<StartBoundary>2016-01-01T06:01:00</StartBoundary>"
- %w%"<Enabled>true</Enabled>"
- %w%"<ScheduleByDay>"
- %w%"<DaysInterval>1</DaysInterval>"
- %w%"</ScheduleByDay>"
- %w%"</CalendarTrigger>"
- %w%"<CalendarTrigger>"
- %w%"<StartBoundary>2016-01-01T12:01:00</StartBoundary>"
- %w%"<Enabled>true</Enabled>"
- %w%"<ScheduleByDay>"
- %w%"<DaysInterval>1</DaysInterval>"
- %w%"</ScheduleByDay>"
- %w%"</CalendarTrigger>"
- %w%"<CalendarTrigger>"
- %w%"<StartBoundary>2016-01-01T18:01:00</StartBoundary>"
- %w%"<Enabled>true</Enabled>"
- %w%"<ScheduleByDay>"
- %w%"<DaysInterval>1</DaysInterval>"
- %w%"</ScheduleByDay>"
- %w%"</CalendarTrigger>"
- %w%"<BootTrigger>"
- %w%"<Enabled>true</Enabled>"
- %w%"<Delay>PT10M</Delay>"
- %w%"</BootTrigger>"
- %w%"<LogonTrigger>"
- %w%"<Enabled>true</Enabled>"
- %w%"</LogonTrigger>"
- %w%"</Triggers>"
- %w%"<Principals>"
- %w%"<Principal id=""Author"">"
- %w%"<UserId>S-1-5-18</UserId>"
- %w%"<RunLevel>HighestAvailable</RunLevel>"
- %w%"</Principal>"
- %w%"</Principals>"
- %w%"<Settings>"
- %w%"<MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>"
- %w%"<DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>"
- %w%"<StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>"
- %w%"<AllowHardTerminate>true</AllowHardTerminate>"
- %w%"<StartWhenAvailable>false</StartWhenAvailable>"
- %w%"<RunOnlyIfNetworkAvailable>true</RunOnlyIfNetworkAvailable>"
- %w%"<IdleSettings>"
- %w%"<StopOnIdleEnd>false</StopOnIdleEnd>"
- %w%"<RestartOnIdle>false</RestartOnIdle>"
- %w%"</IdleSettings>"
- %w%"<AllowStartOnDemand>true</AllowStartOnDemand>"
- %w%"<Enabled>true</Enabled>"
- %w%"<Hidden>false</Hidden>"
- %w%"<RunOnlyIfIdle>false</RunOnlyIfIdle>"
- %w%"<WakeToRun>false</WakeToRun>"
- %w%"<ExecutionTimeLimit>P3D</ExecutionTimeLimit>"
- %w%"<Priority>7</Priority>"
- %w%"</Settings>"
- %w%"<Actions Context=""Author"">"
- %w%"<Exec>"
- %w%"<Command>""" ^& FSO.GetParentFolderName^(Wscript.ScriptFullName^) ^& "\bin\WDU.cmd" ^& """</Command>"
- %w%"</Exec>"
- %w%"</Actions>"
- %w%"</Task>"
- )>>task.vbs
- )
- if /i %1==wub_task (
- rem
- rem Create Windows Update Blocker "Wub_task" that sets your desired Windows Update service state at boot.
- rem
- rem Create Wub_task
- rem
- rem
- (
- %w%"<?xml version=""1.0"" encoding=""UTF-16""?>"
- %w%"<Task version=""1.2"" xmlns=""http://schemas.microsoft.com/windows/2004/02/mit/task"">"
- %w%"<RegistrationInfo>"
- %w%"<Date>2016-02-18T08:29:39</Date>"
- %w%"<Author>pf100\rpo</Author>"
- %w%"<URI>\wub_task</URI>"
- %w%"</RegistrationInfo>"
- %w%"<Triggers>"
- %w%"<BootTrigger>"
- %w%"<Enabled>true</Enabled>"
- %w%"</BootTrigger>"
- %w%"<LogonTrigger>"
- %w%"<Enabled>true</Enabled>"
- %w%"</LogonTrigger>"
- %w%"</Triggers>"
- %w%"<Principals>"
- %w%"<Principal id=""Author"">"
- %w%"<RunLevel>HighestAvailable</RunLevel>"
- %w%"</Principal>"
- %w%"</Principals>"
- %w%"<Settings>"
- %w%"<MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>"
- %w%"<DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>"
- %w%"<StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>"
- %w%"<AllowHardTerminate>true</AllowHardTerminate>"
- %w%"<StartWhenAvailable>true</StartWhenAvailable>"
- %w%"<RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>"
- %w%"<IdleSettings>"
- %w%"<StopOnIdleEnd>false</StopOnIdleEnd>"
- %w%"<RestartOnIdle>false</RestartOnIdle>"
- %w%"</IdleSettings>"
- %w%"<AllowStartOnDemand>true</AllowStartOnDemand>"
- %w%"<Enabled>true</Enabled>"
- %w%"<Hidden>false</Hidden>"
- %w%"<RunOnlyIfIdle>false</RunOnlyIfIdle>"
- %w%"<WakeToRun>false</WakeToRun>"
- %w%"<ExecutionTimeLimit>PT72H</ExecutionTimeLimit>"
- %w%"<Priority>7</Priority>"
- %w%"</Settings>"
- %w%"<Actions Context=""Author"">"
- %w%"<Exec>"
- %w%"<Command>""" ^& FSO.GetParentFolderName^(Wscript.ScriptFullName^) ^& "\bin\Wub.exe""</Command>"
- %w%"<Arguments>/d /p</Arguments>"
- %w%"</Exec>"
- %w%"</Actions>"
- %w%"</Task>"
- )>>task.vbs
- )
- echo f.Close>>task.vbs & task.vbs
- ::
- schtasks /delete /tn "%1" /f >nul 2>&1
- schtasks /create /tn "\Microsoft\Sledgehammer\%1" /ru "SYSTEM" /xml task.xml /F >nul 2>&1 || (
- cls&echo.&echo Creating %2 %1 task errored.&echo.&echo.&echo Press any key to exit... & pause > nul &exit)
- del task.vbs task.xml >nul 2>&1
- exit /b
- ::::::::::::::::::::::::::::
- :wuauserv
- if /i "%1"=="e" (set "wub=wub.exe /e" & set "status=True") else (set "wub=wub.exe /d /p" & set "status=False")
- timeout -t 1 > nul
- .\bin\%wub%
- set /a "max_retry=10" & set /a "i=0"
- :wuauserv1
- if %i%==%max_retry% (echo Operation did not complete within %max_retry% s. Press any key do exit...&pause>nul&exit)
- set /a "i+=1"
- WMIC Service WHERE "Name = 'Wuauserv'" GET Started | find /i "%status%" >nul && exit /b || (timeout /t 1 >nul & goto :wuauserv1)
- ::::::::::::::::::::::::::::
- :StartWUMT
- cls
- (
- echo @echo off
- echo :loop
- echo net start wuauserv
- echo timeout /t 10
- echo goto loop
- )>WU-keep-alive.cmd
- (
- echo @echo off
- echo cd /d "%%~dp0"
- echo del WU-keep-alive.cmd
- echo .\bin\wub.exe /d /p
- echo del close.cmd ^& exit
- )>close.cmd
- if not defined WuMgr (
- set check_updates="%wumt%" -update "-onclose close.cmd"
- ) else (
- set check_updates=.\bin\wumgr.exe -update -online 7971f918-a847-4430-9279-4a52d1efe18d -provisioned -onclose close.cmd)
- call :wuauserv e
- echo CreateObject^("WScript.Shell"^).Run "WU-keep-alive.cmd",0 >WU-keep-alive.vbs&WU-keep-alive.vbs&del WU-keep-alive.vbs
- Start "" %check_updates%
- exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement