fix: 子脚本用户取消安装时返回非零退出码,避免父脚本误报成功
子脚本取消时 exit 0 改为 exit 1,父脚本 Invoke-RemoteSetup 仅依赖 LASTEXITCODE 判断结果(| Out-Host 导致 $? 不可靠)。
This commit is contained in:
@@ -469,7 +469,7 @@ function Main {
|
||||
|
||||
if ($install -eq "n" -or $install -eq "N") {
|
||||
Write-Info "已取消"
|
||||
exit 0
|
||||
exit 1
|
||||
}
|
||||
|
||||
if (-not (Install-Tool)) {
|
||||
|
||||
@@ -471,7 +471,7 @@ function Main {
|
||||
|
||||
if ($install -eq "n" -or $install -eq "N") {
|
||||
Write-Info "已取消"
|
||||
exit 0
|
||||
exit 1
|
||||
}
|
||||
|
||||
if (-not (Install-Tool)) {
|
||||
|
||||
@@ -485,7 +485,7 @@ function Main {
|
||||
|
||||
if ($install -eq "n" -or $install -eq "N") {
|
||||
Write-Info "已取消"
|
||||
exit 0
|
||||
exit 1
|
||||
}
|
||||
|
||||
if (-not (Install-Tool)) {
|
||||
|
||||
@@ -468,7 +468,7 @@ function Main {
|
||||
|
||||
if ($install -eq "n" -or $install -eq "N") {
|
||||
Write-Info "已取消"
|
||||
exit 0
|
||||
exit 1
|
||||
}
|
||||
|
||||
if (-not (Install-Tool)) {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user