Windows: Add running check on uninstaller.

This commit is contained in:
Julien Wadel 2025-01-07 15:21:10 +01:00
parent 773faddd7c
commit 001a4b1bc4

View file

@ -291,6 +291,27 @@ Function AddToPath
Pop $0 Pop $0
FunctionEnd FunctionEnd
Function checkRunning
retry:
ClearErrors
ExecWait '"cmd" /C ""%SystemRoot%\System32\tasklist" /NH /FI "IMAGENAME eq @CPACK_NSIS_MUI_FINISHPAGE_RUN@" | "%SystemRoot%\System32\find" /I /C "@CPACK_NSIS_MUI_FINISHPAGE_RUN@""' $0
IntCmp $0 1 notRunning
MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION "@CPACK_NSIS_MUI_FINISHPAGE_RUN@ is running. Please close it first from the application menu and restart the installation." /SD IDCANCEL IDRETRY retry
Abort
notRunning:
FunctionEnd
;Duplicate function because of shitty behavior of NSIS that need "un." form for uninstaller.
Function un.checkRunning
retry:
ClearErrors
ExecWait '"cmd" /C ""%SystemRoot%\System32\tasklist" /NH /FI "IMAGENAME eq @CPACK_NSIS_MUI_FINISHPAGE_RUN@" | "%SystemRoot%\System32\find" /I /C "@CPACK_NSIS_MUI_FINISHPAGE_RUN@""' $0
IntCmp $0 1 notRunning
MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION "@CPACK_NSIS_MUI_FINISHPAGE_RUN@ is running. Please close it first from the application menu and restart the installation." /SD IDCANCEL IDRETRY retry
Abort
notRunning:
FunctionEnd
; RemoveFromPath - Remove a given dir from the path ; RemoveFromPath - Remove a given dir from the path
; Input: head of the stack ; Input: head of the stack
@ -801,7 +822,9 @@ FunctionEnd
;-------------------------------- ;--------------------------------
; determine admin versus local install ; determine admin versus local install
Function un.onInit Function un.onInit
Call un.checkRunning
ClearErrors ClearErrors
UserInfo::GetName UserInfo::GetName
IfErrors noLM IfErrors noLM
@ -963,13 +986,10 @@ SectionEnd
; "Program Files" for AllUsers, "My Documents" for JustMe... ; "Program Files" for AllUsers, "My Documents" for JustMe...
Function .onInit Function .onInit
retry: Call checkRunning
ClearErrors
ExecWait '"cmd" /C ""%SystemRoot%\System32\tasklist" /NH /FI "IMAGENAME eq @CPACK_NSIS_MUI_FINISHPAGE_RUN@" | "%SystemRoot%\System32\find" /I /C "@CPACK_NSIS_MUI_FINISHPAGE_RUN@""' $0
IntCmp $0 1 notRunning
MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION "@CPACK_NSIS_MUI_FINISHPAGE_RUN@ is running. Please close it first from the application menu and restart the installation." /SD IDCANCEL IDRETRY retry
Abort
notRunning: notRunning: