Skip to content

Commit cdf981e

Browse files
committed
Enhance validation-testing
...added because linting showed we had available testing-material that we weren't using. May as well use it to improve robustness of the script's validation-testing?
1 parent dc89ddb commit cdf981e

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

notepad-plusplus/files/npp_uninstall.ps1

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,22 @@ if (Test-Path $Uninstaller) {
2121
Write-Output "Found uninstaller at '$Uninstaller'"
2222
Write-Output "Executing silent uninstallation..."
2323

24-
# Start the uninstaller with the /S (Silent) flag
24+
# Start the uninstaller and capture the process object
2525
$Proc = Start-Process -FilePath "$Uninstaller" -ArgumentList "/S" -Wait -PassThru
2626

27+
# Use the variable to provide meaningful output and logic
28+
Write-Output "Uninstaller exited with code: $($Proc.ExitCode)"
29+
2730
# Optional: Wait briefly for file system hooks to release
2831
Start-Sleep -Seconds 2
2932

30-
# FINAL VERIFICATION
31-
if (-not (Test-Path $NppExe)) {
33+
# FINAL VERIFICATION: Check both the file system AND the exit code
34+
if (-not (Test-Path $NppExe) -and $Proc.ExitCode -eq 0) {
3235
Write-Output "State: Success"
3336
exit 0
37+
} elseif ($Proc.ExitCode -ne 0) {
38+
Write-Error "State: Failed. Uninstaller returned non-zero exit code ($($Proc.ExitCode))"
39+
exit 1
3440
} else {
3541
Write-Error "State: Failed to remove binary"
3642
exit 1

0 commit comments

Comments
 (0)