fix(collector): pre-launch XML parse-check (fail to default) + resolve setup.exe path

This commit is contained in:
sysadmin
2026-06-10 09:25:57 +01:00
parent 9d05a4a223
commit 084dd6a1d7
2 changed files with 9 additions and 3 deletions

View File

@@ -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)
})

View File

@@ -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