Private
Public Access
1
0

fix: 子脚本用户取消安装时返回非零退出码,避免父脚本误报成功

子脚本取消时 exit 0 改为 exit 1,父脚本 Invoke-RemoteSetup
仅依赖 LASTEXITCODE 判断结果(| Out-Host 导致 $? 不可靠)。
This commit is contained in:
2026-03-20 23:37:15 +08:00
parent fcb8c5e45e
commit 9954678c4f
5 changed files with 7 additions and 6 deletions

View File

@@ -314,8 +314,9 @@ function Invoke-RemoteSetup {
Remove-Item $tempFile -ErrorAction SilentlyContinue
# 检查执行结果
if (-not $scriptSucceeded -or $exitCode -ne 0) {
Write-Error "配置脚本执行失败,退出码: $exitCode"
# 注意: | Out-Host 使 $? 始终为 $true仅依赖 $LASTEXITCODE
if ($exitCode -ne 0) {
Write-Warning "配置脚本未完成 (退出码: $exitCode)"
return $false
}