diff --git a/windows/collector/Collector.ps1 b/windows/collector/Collector.ps1 index 512034e..2e725fc 100644 --- a/windows/collector/Collector.ps1 +++ b/windows/collector/Collector.ps1 @@ -235,7 +235,11 @@ try { Set-Content -Path 'X:\sm\unattend.generated.xml' -Value $xml -Encoding UTF8 - Start-Process -FilePath 'X:\sources\setup.exe' -ArgumentList '/unattend:X:\sm\unattend.generated.xml' -Wait + try { [void][xml](Get-Content 'X:\sm\unattend.generated.xml' -Raw) } + catch { [Environment]::Exit(1) } # bad XML -> fall back to default answer file + + $setup = if (Test-Path 'X:\sources\setup.exe') { 'X:\sources\setup.exe' } else { 'X:\setup.exe' } + Start-Process -FilePath $setup -ArgumentList '/unattend:X:\sm\unattend.generated.xml' -Wait [Environment]::Exit(0) }) diff --git a/windows/collector/Start-Collector.cmd b/windows/collector/Start-Collector.cmd index 79f3c9d..68e639a 100644 --- a/windows/collector/Start-Collector.cmd +++ b/windows/collector/Start-Collector.cmd @@ -1,13 +1,15 @@ @echo off +set "SETUP=X:\sources\setup.exe" +if not exist "%SETUP%" set "SETUP=X:\setup.exe" REM WinPE entry point. SM_UNATTENDED=1 -> skip the UI and launch Setup with the default REM answer file (used by CI / non-interactive builds). if "%SM_UNATTENDED%"=="1" ( - start /wait X:\sources\setup.exe /unattend:X:\autounattend.xml + start /wait "%SETUP%" /unattend:X:\autounattend.xml exit /b 0 ) powershell -NoProfile -ExecutionPolicy Bypass -File X:\sm\Collector.ps1 if errorlevel 1 ( REM Collector failed or was cancelled -> fall back to the default answer file so install still proceeds. - start /wait X:\sources\setup.exe /unattend:X:\autounattend.xml + start /wait "%SETUP%" /unattend:X:\autounattend.xml ) exit /b 0