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

@@ -469,7 +469,7 @@ function Main {
if ($install -eq "n" -or $install -eq "N") { if ($install -eq "n" -or $install -eq "N") {
Write-Info "已取消" Write-Info "已取消"
exit 0 exit 1
} }
if (-not (Install-Tool)) { if (-not (Install-Tool)) {

View File

@@ -471,7 +471,7 @@ function Main {
if ($install -eq "n" -or $install -eq "N") { if ($install -eq "n" -or $install -eq "N") {
Write-Info "已取消" Write-Info "已取消"
exit 0 exit 1
} }
if (-not (Install-Tool)) { if (-not (Install-Tool)) {

View File

@@ -485,7 +485,7 @@ function Main {
if ($install -eq "n" -or $install -eq "N") { if ($install -eq "n" -or $install -eq "N") {
Write-Info "已取消" Write-Info "已取消"
exit 0 exit 1
} }
if (-not (Install-Tool)) { if (-not (Install-Tool)) {

View File

@@ -468,7 +468,7 @@ function Main {
if ($install -eq "n" -or $install -eq "N") { if ($install -eq "n" -or $install -eq "N") {
Write-Info "已取消" Write-Info "已取消"
exit 0 exit 1
} }
if (-not (Install-Tool)) { if (-not (Install-Tool)) {

View File

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