How enable Microsoft update?

Discussion in 'Windows 7' started by George King, Dec 11, 2020.

  1. George King

    George King MDL Expert

    Aug 5, 2009
    1,854
    2,179
    60
    #1 George King, Dec 11, 2020
    Last edited: Dec 11, 2020
    I'm integrating Windows Update Client and also its registred as Microsoft update.
    But all the time after install I need to click in Windows Update on link then allow it in popup Window..

    Anybody know how to force set it? And automatically search updates for all Microsoft Products?

    This is what I'm integrating
    Code:
    REM KB901037 Microsoft Update
    "%DISMX%" /image:"%IMAGE%" /add-package /packagepath:"%~dp0updates\extracted\WUClient-SelfUpdate-ActiveX-%ARCH%\update.mum" /LogLevel:%DISMErrorLevel% /LogPath:"%~dp0Logs\%INDEX%\Update.log"
    "%DISMX%" /image:"%IMAGE%" /add-package /packagepath:"%~dp0updates\extracted\WUClient-SelfUpdate-Aux-TopLevel-%ARCH%\update.mum" /LogLevel:%DISMErrorLevel% /LogPath:"%~dp0Logs\%INDEX%\Update.log"
    "%DISMX%" /image:"%IMAGE%" /add-package /packagepath:"%~dp0updates\extracted\WUClient-SelfUpdate-Core-TopLevel-%ARCH%\update.mum" /LogLevel:%DISMErrorLevel% /LogPath:"%~dp0Logs\%INDEX%\Update.log"
    if exist "%IMAGE%\Windows\System32\wuapp.exe" (
        reg load HKLM\TempSoftware "%IMAGE%\windows\system32\config\Software" >nul
        reg add "HKLM\TempSoftware\Microsoft\Windows\CurrentVersion\WindowsUpdate\Services\Pending\7971f918-a847-4430-9279-4a52d1efe18d" /v "ClientApplicationID" /t REG_SZ /d "My App" /f >nul
        reg add "HKLM\TempSoftware\Microsoft\Windows\CurrentVersion\WindowsUpdate\Services\Pending\7971f918-a847-4430-9279-4a52d1efe18d" /v "RegisterWithAU" /t REG_DWORD /d 1 /f >nul
        reg unload HKLM\TempSoftware >nul
    )
    

    EDIT: Maybe I found that key, going to try it in offline image
    Code:
    reg add "HKLM\TempSoftware\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update" /v "EnableFeaturedSoftware" /t REG_DWORD /d 1 /f >nul
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  2. Enthousiast

    Enthousiast MDL Tester

    Oct 30, 2009
    47,262
    94,706
    450
    Old setupcomplete trick by @murphy78:
    Code:
    @echo off
    
    echo Set ServiceManager = CreateObject^("Microsoft.Update.ServiceManager"^)>%TEMP%\MSU.vbs
    echo ServiceManager.ClientApplicationID = "My App">>%TEMP%\MSU.vbs
    echo Set NewUpdateService = ServiceManager.AddService2^("7971f918-a847-4430-9279-4a52d1efe18d",7,""^)>>%TEMP%\MSU.vbs
    %windir%\system32\wscript.exe "%TEMP%\MSU.vbs" >nul
     
  3. George King

    George King MDL Expert

    Aug 5, 2009
    1,854
    2,179
    60
    Thanks guys, but it can be done into offine image without these scripts. My goal was to prepare it inside image without running script on installed Windows or during setup.

    I tested it now and it works as expected. These reg keys enable Microsoft update in offline image.
    Code:
        reg load HKLM\TempSoftware "%ASSIGNLETTER%:\windows\system32\config\Software" >nul
        reg add "HKLM\TempSoftware\Microsoft\Windows\CurrentVersion\WindowsUpdate\Services\Pending\7971f918-a847-4430-9279-4a52d1efe18d" /v "ClientApplicationID" /t REG_SZ /d "My App" /f >nul
        reg add "HKLM\TempSoftware\Microsoft\Windows\CurrentVersion\WindowsUpdate\Services\Pending\7971f918-a847-4430-9279-4a52d1efe18d" /v "RegisterWithAU" /t REG_DWORD /d 1 /f >nul
        reg add "HKLM\TempSoftware\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update" /v "EnableFeaturedSoftware" /t REG_DWORD /d 1 /f >nul
        reg unload HKLM\TempSoftware >nul 
    
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. Reducer

    Reducer MDL Junior Member

    Jul 30, 2014
    51
    69
    0
    I'm a total beginner at ps... What's the proper way to script such command in a .cmd file?
     
  5. abbodi1406

    abbodi1406 MDL KB0000001

    Feb 19, 2011
    16,209
    84,855
    340
    Code:
    powershell -nop -c "(new-object -c 'Microsoft.Update.ServiceManager').AddService2('7971f918-a847-4430-9279-4a52d1efe18d',7,'')"
    make sure it's admin cmd
     
  6. abbodi1406

    abbodi1406 MDL KB0000001

    Feb 19, 2011
    16,209
    84,855
    340
    #7 abbodi1406, Jul 10, 2023
    Last edited: Jul 10, 2023
    Batch version, non vbscript/powershell, because why not
    pre Win 10
    Code:
    @echo off
    set "_m=7971f918-a847-4430-9279-4a52d1efe18d"
    set "_w=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate"
    set "_u=%_w%\Auto Update"
    net stop wuauserv 2>nul
    reg delete "%_w%\Services" /f /v "DefaultService" 2>nul
    reg delete "%_w%\Services\%_m%" /f 2>nul
    reg add "%_w%\Services\Pending\%_m%" /f /v "RegisterWithAU" /t REG_DWORD /d 1
    reg add "%_w%\Services\Pending" /f /v "ValidatedPreWsus3RegistrationRequests" /t REG_DWORD /d 1
    net start wuauserv 2>nul
    ping localhost >nul
    reg query "%_u%" /v AUOptions 2>nul | find /i "0x1" 1>nul && (reg add "%_u%" /f /v "AUOptions" /t REG_DWORD /d 2&reg add "%_u%" /f /v "AUOptions_bak" /t REG_DWORD /d 1)
    wuauclt.exe /DetectNow
    ping localhost >nul
    reg query "%_u%" /v AUOptions_bak 1>nul 2>nul && (reg add "%_u%" /f /v "AUOptions" /t REG_DWORD /d 1&reg delete "%_u%" /f /v "AUOptions_bak")
    exit /b
    
    Win 10/11
    Code:
    @echo off
    set "_m=7971f918-a847-4430-9279-4a52d1efe18d"
    set "_w=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate"
    net stop usosvc 2>nul
    net stop wuauserv 2>nul
    reg delete "%_w%\Services" /f /v "DefaultService" 2>nul
    reg delete "%_w%\Services\%_m%" /f 2>nul
    reg add "%_w%\Services\Pending\%_m%" /f /v "RegisterWithAU" /t REG_DWORD /d 1
    reg add "%_w%\Services\Pending" /f /v "ValidatedPreWsus3RegistrationRequests" /t REG_DWORD /d 1
    del /f /q %ProgramData%\USOPrivate\UpdateStore\*
    net start wuauserv 2>nul
    net start usosvc 2>nul
    ping localhost >nul
    UsoClient.exe RefreshSettings
    exit /b
    
    Or for all
    Code:
    @echo off
    pushd "%SystemRoot%\System32\"
    set "_m=7971f918-a847-4430-9279-4a52d1efe18d"
    set "_w=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate"
    set "_u=%_w%\Auto Update"
    if exist "UsoClient.exe" net stop usosvc 2>nul
    net stop wuauserv 2>nul
    reg delete "%_w%\Services" /f /v "DefaultService" 2>nul
    reg delete "%_w%\Services\%_m%" /f 2>nul
    reg add "%_w%\Services\Pending\%_m%" /f /v "RegisterWithAU" /t REG_DWORD /d 1
    reg add "%_w%\Services\Pending" /f /v "ValidatedPreWsus3RegistrationRequests" /t REG_DWORD /d 1
    if exist "UsoClient.exe" del /f /q %ProgramData%\USOPrivate\UpdateStore\*
    net start wuauserv 2>nul
    if exist "UsoClient.exe" net start usosvc 2>nul
    ping localhost >nul
    reg query "%_u%" /v AUOptions 2>nul | find /i "0x1" 1>nul && (reg add "%_u%" /f /v "AUOptions" /t REG_DWORD /d 2&reg add "%_u%" /f /v "AUOptions_bak" /t REG_DWORD /d 1)
    if exist "UsoClient.exe" (UsoClient.exe RefreshSettings) else (wuauclt.exe /DetectNow)
    ping localhost >nul
    reg query "%_u%" /v AUOptions_bak 1>nul 2>nul && (reg add "%_u%" /f /v "AUOptions" /t REG_DWORD /d 1&reg delete "%_u%" /f /v "AUOptions_bak")
    exit /b
    
     
  7. Carlos Detweiller

    Carlos Detweiller Emperor of Ice-Cream

    Dec 21, 2012
    6,341
    7,060
    210
    Thanks. Problem with the PS version is that, by default, it will deny executing random scripts you throw at it. The batch version should work OOB.