diff --git a/windows/installer/build.ps1 b/windows/installer/build.ps1 index 7a6e78d..6208a27 100644 --- a/windows/installer/build.ps1 +++ b/windows/installer/build.ps1 @@ -96,14 +96,18 @@ function Invoke-ForceLegacySetup { if (-not (Test-Path $bootwim)) { throw "boot.wim not found: $bootwim" } Mount-WindowsImage -ImagePath $bootwim -Index 2 -Path $bootmnt | Out-Null try { - $cmdline = 'X:\sources\setup.exe' - if (-not (Test-Path (Join-Path $bootmnt 'sources\setup.exe')) -and - (Test-Path (Join-Path $bootmnt 'setup.exe'))) { $cmdline = 'X:\setup.exe' } + # Inject the answer file into the WinPE image at a fixed X: path, and launch + # legacy setup with an EXPLICIT /unattend -- the implicit media search is + # unreliable when setup is launched via the CmdLine override (legacy Setup + # otherwise still shows the language page). + Copy-Item (Join-Path $PSScriptRoot 'autounattend\autounattend.xml') (Join-Path $bootmnt 'autounattend.xml') -Force + $setup = if (Test-Path (Join-Path $bootmnt 'sources\setup.exe')) { 'X:\sources\setup.exe' } else { 'X:\setup.exe' } + $cmdline = "$setup /unattend:X:\autounattend.xml" $hive = Join-Path $bootmnt 'Windows\System32\config\SYSTEM' & reg load 'HKLM\SM_BOOT' $hive | Out-Null try { & reg add 'HKLM\SM_BOOT\Setup' /v CmdLine /t REG_SZ /d $cmdline /f | Out-Null - Write-Host " WinPE Setup\CmdLine = $cmdline (legacy Setup forced)" + Write-Host " WinPE Setup\CmdLine = $cmdline (legacy Setup + explicit unattend)" } finally { [gc]::Collect(); Start-Sleep -Seconds 2 & reg unload 'HKLM\SM_BOOT' | Out-Null