Skip to content

Commit 282fc72

Browse files
committed
fix: one-click CHECK_APP_RUNNING before SetSilent
"if I click Uninstall while App is running, nothing happens...I assume exception is swallowed silently? Should we also prompt like install "Click OK to close running app..."
1 parent b3c49cb commit 282fc72

File tree

2 files changed

+26
-21
lines changed

2 files changed

+26
-21
lines changed

templates/nsis/allowOnlyOneInstallerInstace.nsh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
!macro CHECK_APP_RUNNING MODE
2626
${nsProcess::FindProcess} "${APP_EXECUTABLE_FILENAME}" $R0
2727
${If} $R0 == 0
28-
MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION "${PRODUCT_NAME} is running. $\r$\nClick OK to close it and continue with ${MODE}." /SD IDCANCEL IDOK doStopProcess
28+
MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION "${PRODUCT_NAME} is running. $\r$\nClick OK to close it and continue with ${MODE}." /SD IDOK IDOK doStopProcess
2929
Quit
3030
doStopProcess:
3131
DetailPrint "Closing running ${PRODUCT_NAME} ..."

templates/nsis/installer.nsi

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -48,25 +48,6 @@ Function .onInit
4848
!endif
4949
FunctionEnd
5050

51-
Function un.onInit
52-
!insertmacro check64BitAndSetRegView
53-
54-
${IfNot} ${Silent}
55-
MessageBox MB_OKCANCEL "Are you sure you want to uninstall ${PRODUCT_NAME}?" IDOK +2
56-
Quit
57-
58-
!ifdef ONE_CLICK
59-
SetSilent silent
60-
!endif
61-
${EndIf}
62-
63-
!insertmacro initMultiUser Un un.
64-
65-
!ifmacrodef customUnInit
66-
!insertmacro customUnInit
67-
!endif
68-
FunctionEnd
69-
7051
Section "install"
7152
${IfNot} ${Silent}
7253
SetDetailsPrint none
@@ -127,10 +108,34 @@ Section "install"
127108
${EndIf}
128109
SectionEnd
129110

111+
Function un.onInit
112+
!insertmacro check64BitAndSetRegView
113+
114+
${IfNot} ${Silent}
115+
MessageBox MB_OKCANCEL "Are you sure you want to uninstall ${PRODUCT_NAME}?" IDOK +2
116+
Quit
117+
118+
!ifdef ONE_CLICK
119+
# one-click installer executes uninstall section in the silent mode, but we must show message dialog if silent mode was not explicitly set by user (using /S flag)
120+
!insertmacro CHECK_APP_RUNNING "uninstall"
121+
SetSilent silent
122+
!endif
123+
${EndIf}
124+
125+
!insertmacro initMultiUser Un un.
126+
127+
!ifmacrodef customUnInit
128+
!insertmacro customUnInit
129+
!endif
130+
FunctionEnd
131+
130132
Section "un.install"
131133
SetAutoClose true
132134

133-
!insertmacro CHECK_APP_RUNNING "uninstall"
135+
!ifndef ONE_CLICK
136+
# for boring installer we check it here to show progress
137+
!insertmacro CHECK_APP_RUNNING "uninstall"
138+
!endif
134139

135140
StrCpy $startMenuLink "$SMPROGRAMS\${PRODUCT_FILENAME}.lnk"
136141
StrCpy $desktopLink "$DESKTOP\${PRODUCT_FILENAME}.lnk"

0 commit comments

Comments
 (0)