Is running this still required even if I chose "notify before downloading and installing" via group policy editor?
I don't remember. Check your updates page. It should mention automatic updates if it still needs to be set.
FYI @ murph: Found that using Code: if %errorlevel% neq 0 can lead to unpredicted behaviour due to the freestanding '0'. So i prefer Code: if not "%errorlevel%"=="0" One could check if thats the issue here, since the check looks valid to me .
The problem I believe is in the way reg query detects a key that isn't present and piping the output to find. I could do 2x reg query but skip the 2nd if the first errors out, but there might be a better way and I don't want to half-a** it. Edit: actually something like this might work: Code: reg query HKLM\Blahblahblah 2>NUL|find /i "hurray">nul 2>NUL You see how it pipes the error channel to nul before the find pipe?
Code: reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" /v "NoAutoUpdate" >NUL if not "%errorlevel%"=="0" GOTO :NOTPRESENT
Just adding the right pair of brackets around your original command seems OK to me: Code: (reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" /v "NoAutoUpdate"|find /i "0x1")>NUL 2>NUL Doesn't emit any output whatsoever, doesn't break the pipe to find, and 1 gets stored in %ERRORLEVEL% when the key doesn't exist (in which case it's fair enough to assume automatic updates are enabled) or when it's set to 0.
Code: @echo off title Disable/Enable Windows 10 Automatic Updates color 1f :Begin UAC check and Auto-Elevate Permissions :------------------------------------- REM --> Check for permissions >nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system" REM --> If error flag set, we do not have admin. if '%errorlevel%' NEQ '0' ( echo: echo Requesting Administrative Privileges... echo Press YES in UAC Prompt to Continue echo: goto UACPrompt ) else ( goto gotAdmin ) :UACPrompt echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs" echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs" "%temp%\getadmin.vbs" exit /B :gotAdmin if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" ) pushd "%CD%" CD /D "%~dp0" :-------------------------------------- ::=============================================================================================================== :Check Windows Version wmic os get version | find /i "10.">nul 2>nul if not "%errorlevel%"=="0" GOTO :Not10 ::=============================================================================================================== :Check the key: reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" /v "NoAutoUpdate" >NUL if not "%errorlevel%"=="0" ( call :HEADER "Reg Key not present.", "Would you like to set now? (Y/N)" CHOICE /C YN /N /M "YOUR CHOICE ?:" if %errorlevel%==2 goto:EXIT call :KEYOFF 1, "dis" pause goto:EXIT ) ::=============================================================================================================== reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" /v "NoAutoUpdate"|find /i "0x1" >NUL if "%errorlevel%"=="0" ( call :HEADER "Automatic Updates are currently enabled.", "Would you like to disable them? (Y/N)" CHOICE /C YN /N /M "YOUR CHOICE ?:" if %errorlevel%==2 goto:EXIT call :KEYOFF 1, "dis" pause goto:EXIT ) if not "%errorlevel%"=="0" ( call :HEADER "Automatic Updates are currently disabled.", "Would you like to enable them? (Y/N)" CHOICE /C YN /N /M "YOUR CHOICE ?:" if %errorlevel%==2 goto:EXIT call :KEYOFF 2, "en" pause goto:EXIT ) ::=============================================================================================================== :KEYOFF echo Attempting to shut down the Windows Update service if it's running net stop wuauserv>NUL 2>NUL echo. Echo Changing Registry key REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" /v "NoAutoUpdate" /D %~1 /T REG_DWORD /F>NUL 2>NUL if not "%errorlevel%"=="0" goto:ERROR Echo. Echo Automatic Updates have been %~abled Echo. goto:eof ::=============================================================================================================== :HEADER echo ============================================================ echo %~1 echo %~2 echo ============================================================ echo. goto:eof ::=============================================================================================================== :QUIT echo ============================================================ echo Press any key to exit... echo ============================================================ pause>NUL exit ::=============================================================================================================== :ERROR echo ============================================================ echo The script ran into an unexpected error setting reg key. echo Press any key to exit... echo ============================================================ pause>NUL exit ::=============================================================================================================== :Not10 echo ============================================================ echo This script is only designed for Windows 10... echo Press any key to exit... echo ============================================================ pause>NUL exit
Love your edit s1ave77. I already uploaded a v3 to the servers and updated OP, tho Perhaps we can use it on a settings script in the future or something? There's a lot of little registry tweaks that are popular like telemetry, defender updates, defender disable, perhaps store auto-update settings... I gotta run soon to pick up my daughter, but perhaps another time?
Didn't battle with parsing the Tweaks Thread Mess so far . Would like to have all needed tweaks at one place, since i will include in JATD also. Wouldn't be that hard to create a manual standalone version likewise thou .
Hard part of a lot of those tweaks is that I have no idea what they do or what they're for so I usually can only judge by the reg key name.
For that reason i initially implemented it. I also use it to check WU without the need to use crappy UI.
@ murph Btw, once one begins to understand how to use call command to hand-over values, one can spare tons of redundant code (JATD lost 3000 lines in last refresh) .
My main issue about forced updates is that it asks me when I want to reboot my computer, and it doesn't give me an option to permanently postpone the reboot. Obviously I will eventually have to reboot my computer, but I host a variety of server-type applications and such and I VERY rarely actually reboot my computer. When I upgrade to Windows 10 it's going to by default force me to reboot every time there's a new windows update that upgrades certain system files. Just by paying attention to the non-build update hotfixes that WU has installed, it's forced me to reboot my computer on average twice a week. Forcing me to reboot my computer every 2-3 days is unacceptable to me and it seems like the only surefire way of preventing this from happening is using murphy78's script to stop the wuaserv service temporarily until I can manually check for updates, install them all, and then reboot.