feat: Hide first-logon console during answer generation (#2152)

This commit is contained in:
Kroese
2026-08-18 02:15:37 +02:00
committed by GitHub
parent a0a4520be6
commit 2bf6ae55ab
+37
View File
@@ -71,6 +71,11 @@ updateXML() {
return 1 return 1
fi fi
if ! updateLogonCommandXML "$asset"; then
error "Failed to update first-logon command in answer file!"
return 1
fi
if ! updateEditionXML "$asset"; then if ! updateEditionXML "$asset"; then
error "Failed to update edition settings in answer file!" error "Failed to update edition settings in answer file!"
return 1 return 1
@@ -521,6 +526,38 @@ updateAutologinXML() {
return 0 return 0
} }
updateLogonCommandXML() {
local asset="$1"
case "${DETECTED,,}" in
"winvista"* ) return 0 ;;
esac
local command="$XML_COMPONENT_SHELL_OOBE/u:FirstLogonCommands/u:SynchronousCommand/u:CommandLine"
local expected='cmd.exe /d /c call "%WINDIR%\Setup\Scripts\SetupComplete.cmd" logon'
local hidden="powershell.exe -NoLogo -NoProfile -NonInteractive -WindowStyle Hidden -Command \"& \$env:ComSpec /d /c ('call ' + [char]34 + \$env:WINDIR + '\Setup\Scripts\SetupComplete.cmd' + [char]34 + ' logon'); exit \$LASTEXITCODE\""
local count value
count=$(getXMLNodeCount "$asset" "$command") || return 1
if [ "$count" != "1" ]; then
error "Failed to find a unique first-logon command in answer file: $asset"
return 1
fi
value=$(xmlstarlet sel -N "$XML_NS_UNATTEND_ARG" -T -t -v "string($command)" "$asset") || return 1
if [ "$value" != "$expected" ]; then
error "Unexpected first-logon command in answer file: $asset"
return 1
fi
xmlstarlet ed -L -N "$XML_NS_UNATTEND_ARG" -u "$command" -v "$hidden" "$asset" || return 1
return 0
}
updateProductKey() { updateProductKey() {
local script="$1" local script="$1"