Skip to content

Commit

Permalink
fix: one-click CHECK_APP_RUNNING before SetSilent
Browse files Browse the repository at this point in the history
"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..."
  • Loading branch information
develar committed Aug 5, 2016
1 parent b3c49cb commit 282fc72
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 21 deletions.
2 changes: 1 addition & 1 deletion templates/nsis/allowOnlyOneInstallerInstace.nsh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
!macro CHECK_APP_RUNNING MODE
${nsProcess::FindProcess} "${APP_EXECUTABLE_FILENAME}" $R0
${If} $R0 == 0
MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION "${PRODUCT_NAME} is running. $\r$\nClick OK to close it and continue with ${MODE}." /SD IDCANCEL IDOK doStopProcess
MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION "${PRODUCT_NAME} is running. $\r$\nClick OK to close it and continue with ${MODE}." /SD IDOK IDOK doStopProcess
Quit
doStopProcess:
DetailPrint "Closing running ${PRODUCT_NAME} ..."
Expand Down
45 changes: 25 additions & 20 deletions templates/nsis/installer.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -48,25 +48,6 @@ Function .onInit
!endif
FunctionEnd

Function un.onInit
!insertmacro check64BitAndSetRegView

${IfNot} ${Silent}
MessageBox MB_OKCANCEL "Are you sure you want to uninstall ${PRODUCT_NAME}?" IDOK +2
Quit

!ifdef ONE_CLICK
SetSilent silent
!endif
${EndIf}

!insertmacro initMultiUser Un un.

!ifmacrodef customUnInit
!insertmacro customUnInit
!endif
FunctionEnd

Section "install"
${IfNot} ${Silent}
SetDetailsPrint none
Expand Down Expand Up @@ -127,10 +108,34 @@ Section "install"
${EndIf}
SectionEnd

Function un.onInit
!insertmacro check64BitAndSetRegView

${IfNot} ${Silent}
MessageBox MB_OKCANCEL "Are you sure you want to uninstall ${PRODUCT_NAME}?" IDOK +2
Quit

!ifdef ONE_CLICK
# 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)
!insertmacro CHECK_APP_RUNNING "uninstall"
SetSilent silent
!endif
${EndIf}

!insertmacro initMultiUser Un un.

!ifmacrodef customUnInit
!insertmacro customUnInit
!endif
FunctionEnd

Section "un.install"
SetAutoClose true

!insertmacro CHECK_APP_RUNNING "uninstall"
!ifndef ONE_CLICK
# for boring installer we check it here to show progress
!insertmacro CHECK_APP_RUNNING "uninstall"
!endif

StrCpy $startMenuLink "$SMPROGRAMS\${PRODUCT_FILENAME}.lnk"
StrCpy $desktopLink "$DESKTOP\${PRODUCT_FILENAME}.lnk"
Expand Down

0 comments on commit 282fc72

Please sign in to comment.