mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-05-13 06:56:06 +00:00
Fix silent sc.exe delete failures in install.ps1
- Add error handling for sc.exe delete in uninstall logic - Add error handling for legacy agent service deletion - Add error handling for existing service deletion before reinstall - Show warnings when service deletion fails instead of silently continuing Related to #735
This commit is contained in:
parent
8afc4d0c6c
commit
bfce323e41
1 changed files with 21 additions and 4 deletions
|
|
@ -120,7 +120,14 @@ if ($Uninstall) {
|
|||
|
||||
if (Get-Service $AgentName -ErrorAction SilentlyContinue) {
|
||||
Stop-Service $AgentName -Force -ErrorAction SilentlyContinue
|
||||
sc.exe delete $AgentName | Out-Null
|
||||
$scOutput = sc.exe delete $AgentName 2>&1
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host "Warning: Failed to delete service: $scOutput" -ForegroundColor Yellow
|
||||
} else {
|
||||
Write-Host "Service deleted successfully" -ForegroundColor Green
|
||||
}
|
||||
} else {
|
||||
Write-Host "Service '$AgentName' not found (already removed)" -ForegroundColor Yellow
|
||||
}
|
||||
|
||||
Remove-Item "$InstallDir\$BinaryName" -Force -ErrorAction SilentlyContinue
|
||||
|
|
@ -236,7 +243,10 @@ Write-Host "Checking for legacy agents..." -ForegroundColor Cyan
|
|||
if (Get-Service "PulseHostAgent" -ErrorAction SilentlyContinue) {
|
||||
Write-Host "Removing legacy PulseHostAgent..." -ForegroundColor Yellow
|
||||
Stop-Service "PulseHostAgent" -Force -ErrorAction SilentlyContinue
|
||||
sc.exe delete "PulseHostAgent" | Out-Null
|
||||
$scOutput = sc.exe delete "PulseHostAgent" 2>&1
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host "Warning: Failed to delete PulseHostAgent service: $scOutput" -ForegroundColor Yellow
|
||||
}
|
||||
Remove-Item "C:\Program Files\Pulse\pulse-host-agent.exe" -Force -ErrorAction SilentlyContinue
|
||||
Start-Sleep -Seconds 2
|
||||
}
|
||||
|
|
@ -244,7 +254,10 @@ if (Get-Service "PulseHostAgent" -ErrorAction SilentlyContinue) {
|
|||
if (Get-Service "PulseDockerAgent" -ErrorAction SilentlyContinue) {
|
||||
Write-Host "Removing legacy PulseDockerAgent..." -ForegroundColor Yellow
|
||||
Stop-Service "PulseDockerAgent" -Force -ErrorAction SilentlyContinue
|
||||
sc.exe delete "PulseDockerAgent" | Out-Null
|
||||
$scOutput = sc.exe delete "PulseDockerAgent" 2>&1
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host "Warning: Failed to delete PulseDockerAgent service: $scOutput" -ForegroundColor Yellow
|
||||
}
|
||||
Remove-Item "C:\Program Files\Pulse\pulse-docker-agent.exe" -Force -ErrorAction SilentlyContinue
|
||||
Start-Sleep -Seconds 2
|
||||
}
|
||||
|
|
@ -254,8 +267,12 @@ Write-Host "Installing binary..." -ForegroundColor Cyan
|
|||
|
||||
# Stop existing service if running
|
||||
if (Get-Service $AgentName -ErrorAction SilentlyContinue) {
|
||||
Write-Host "Removing existing $AgentName service..." -ForegroundColor Yellow
|
||||
Stop-Service $AgentName -Force -ErrorAction SilentlyContinue
|
||||
sc.exe delete $AgentName | Out-Null
|
||||
$scOutput = sc.exe delete $AgentName 2>&1
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host "Warning: Failed to delete existing service: $scOutput" -ForegroundColor Yellow
|
||||
}
|
||||
Start-Sleep -Seconds 2
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue