Windows update toggle start/stop/disable batch file

Discussion in 'Scripting' started by Hackeur, Dec 13, 2016.

  1. Hackeur

    Hackeur MDL Senior Member

    Jun 14, 2009
    330
    441
    10
    #1 Hackeur, Dec 13, 2016
    Last edited by a moderator: Apr 20, 2017
    a little experiment with Windows update start/stop/disable in a single batch file:

    Code:
    @echo off
    color 1F
    set service=wuauserv
    
    sc query %service% | find "RUNNING"
    if "%ERRORLEVEL%"=="0" (
        net stop %service%
        sc config %service% start= disabled
    ) else (
        sc config %service% start= demand
        net start %service%
    )
    
    timeout /t 2
    
    sc query %service% >>TEMPmessage.txt
    msg %username% /time:20 <TEMPmessage.txt
    del TEMPmessage.txt /f /q
    exit
    
    any suggestions to improve the script are most welcomed.
     
  2. LiteOS

    LiteOS Windowizer

    Mar 7, 2014
    2,204
    978
    90
    maybe
    sc config %service% start= disabled || sc config %service% start= demand
    net stop %service% || net start %service%
     
  3. Hackeur

    Hackeur MDL Senior Member

    Jun 14, 2009
    330
    441
    10
    just tried your script but the toggle "sc config" does not seem to work, only works with the "net" command.

    thanks for your input.

    when Windows update is stopped I want the service disabled.
     
  4. TairikuOkami

    TairikuOkami MDL Expert

    Mar 15, 2014
    1,172
    1,055
    60
    You might add this, if the service is being started, to jump directly to checking for updates, even simulate pressing enter. The "en-us" part is dependable on your language version.

    %localappdata%\Packages\windows.immersivecontrolpanel_cw5n1h2txyewy\LocalState\Indexed\Settings\en-US\AAA_SystemSettings_MusUpdate_UpdateActionButton.settingcontent-ms