From 410e59b5074e4accc8e697dbc031365c42ab7e89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20Br=C3=BCbach?= Date: Mon, 21 Sep 2026 18:43:47 +0200 Subject: [PATCH] [Windows] Fix exit-code detection in the uninstaller process check --- cmake/NSIS.template.in | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/cmake/NSIS.template.in b/cmake/NSIS.template.in index 8631e72f6..8484fe9be 100644 --- a/cmake/NSIS.template.in +++ b/cmake/NSIS.template.in @@ -308,12 +308,17 @@ FunctionEnd ; Uninstaller copies of the same routines (the uninstaller gets its own ; function set compiled in, it cannot call the installer functions). Function un.IsAppRunning - nsExec::ExecToLog 'powershell -NoProfile -Command "Get-Process -Name $\'$R2$\' -ErrorAction SilentlyContinue | Where-Object { $$_.Path -like $\'$INSTDIR\*$\' } | Select-Object -First 1"' + ; Exit the process explicitly so nsExec's pop reflects whether a matching + ; process was found: powershell.exe exits 0 whether or not the pipeline + ; produced objects. Any other result (exit 1, or nsExec's "error" string + ; when powershell itself cannot be started) is treated as "running" so the + ; lock guard fails closed. + nsExec::ExecToLog 'powershell -NoProfile -Command "if (Get-Process -Name $\'$R2$\' -ErrorAction SilentlyContinue | Where-Object { $$_.Path -like $\'$INSTDIR\*$\' } | Select-Object -First 1) { exit 1 } else { exit 0 }"' Pop $R0 - ${If} $R0 = 0 - StrCpy $R0 1 - ${Else} + ${If} $R0 == "0" StrCpy $R0 0 + ${Else} + StrCpy $R0 1 ${EndIf} FunctionEnd