fix: force MSI uninstall flag /X and pause between uninstall steps
This commit is contained in:
@@ -319,22 +319,30 @@ function Invoke-UninstallSoftware {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
# Use Quiet String if available? No, user requested "Non Quietly" to debug.
|
# Use Quiet String if available? No, user requested "Non Quietly" to debug.
|
||||||
# But if standard fails, we see it now.
|
# But if standard fails, we see it now.
|
||||||
$finalCmd = "$rawCmd"
|
$finalCmd = "$rawCmd"
|
||||||
|
|
||||||
Write-Host " Executing: $($finalCmd)" -ForegroundColor Cyan
|
# FIX: Some MSI commands use /I (Install/Configure) instead of /X (Uninstall).
|
||||||
|
# We force /X to ensure it triggers the removal process.
|
||||||
|
if ($finalCmd -match "(?i)msiexec.*\/I\s*{") {
|
||||||
|
Write-Host " [!] Detected MSI Install flag (/I). Swapping to Uninstall flag (/X)..." -ForegroundColor Magenta
|
||||||
|
$finalCmd = $finalCmd -replace "(?i)\/I", "/X"
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
Write-Host " Executing: $($finalCmd)" -ForegroundColor Cyan
|
||||||
# Use WindowStyle Normal so the user can see the uninstaller
|
|
||||||
Start-Process -FilePath "cmd.exe" -ArgumentList "/c", "$finalCmd" -Wait -WindowStyle Normal
|
try {
|
||||||
} catch {
|
# Use WindowStyle Normal so the user can see the uninstaller
|
||||||
Write-Host " [!] Error launching: $($_.Exception.Message)" -ForegroundColor Red
|
Start-Process -FilePath "cmd.exe" -ArgumentList "/c", "$finalCmd" -Wait -WindowStyle Normal
|
||||||
}
|
} catch {
|
||||||
Start-Sleep -Seconds 1
|
Write-Host " [!] Error launching: $($_.Exception.Message)" -ForegroundColor Red
|
||||||
}
|
}
|
||||||
Write-Progress -Activity "Uninstalling Software" -Completed
|
|
||||||
Write-Host "`nDone processing list." -ForegroundColor Green
|
Write-Host " (Press ENTER to continue to next app...)" -ForegroundColor DarkGray
|
||||||
|
[void](Read-Host)
|
||||||
|
}
|
||||||
|
Write-Progress -Activity "Uninstalling Software" -Completed Write-Host "`nDone processing list." -ForegroundColor Green
|
||||||
Wait-Key
|
Wait-Key
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user