Skip to content

Commit

Permalink
Merge pull request #13 from dalthviz/spyder-kill-child-process
Browse files Browse the repository at this point in the history
PR: Add flag to kill child processes if Spyder is open while running installer and fixes uninstall failing validation
  • Loading branch information
dalthviz authored Jul 11, 2022
2 parents 441822d + 0e00c23 commit c9fc275
Showing 1 changed file with 23 additions and 11 deletions.
34 changes: 23 additions & 11 deletions nsist/spyder.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ SetCompressor lzma
!define MUI_PAGE_CUSTOMFUNCTION_PRE validate_pre_install
!insertmacro MUI_PAGE_WELCOME
[% if license_file %]
!define MUI_PAGE_CUSTOMFUNCTION_PRE validate_updating_and_skip
!insertmacro MUI_PAGE_LICENSE [[license_file]]
[% endif %]
!insertmacro MULTIUSER_PAGE_INSTALLMODE
Expand All @@ -59,8 +60,10 @@ Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "${INSTALLER_NAME}"
ShowInstDetails show

; Variables used globally
Var cmdLineInstallDir
Var uninstallPreviousInstallation
Var updatingInstallation

Section -SETTINGS
SetOutPath "$INSTDIR"
Expand Down Expand Up @@ -268,14 +271,17 @@ Function validate_pre_install

FindWindow $0 "" "${PRODUCT_NAME}"
IntCmp $0 0 notRunning
MessageBox MB_YESNO|MB_ICONINFORMATION "${PRODUCT_NAME} is running. You will need to close it first to proceed. Do you want to close ${PRODUCT_NAME} now?" \
MessageBox MB_YESNO|MB_ICONINFORMATION "${PRODUCT_NAME} is running. It is necessary to close it before installing a new version. Do you want to close ${PRODUCT_NAME} now?" \
/SD IDYES IDYES Confirm IDNO NoClose
Confirm:
MessageBox MB_YESNO|MB_ICONINFORMATION "All unsaved files and changes will be lost. All ${PRODUCT_NAME} running processes will stop. Are you sure you are want to close ${PRODUCT_NAME}?" \
MessageBox MB_YESNO|MB_ICONINFORMATION "All unsaved files and changes will be lost. In addition, any program that you are running in ${PRODUCT_NAME}'s IPython console will be stopped. \
$\r$\n$\r$\nAre you sure you want to close ${PRODUCT_NAME}?" \
/SD IDYES IDYES CloseSpyder IDNO NoClose
CloseSpyder:
nsExec::Exec 'TaskKill /FI "WINDOWTITLE eq Spyder" /F'
goto notRunning
Banner::show /set 76 "Please wait while closing ${PRODUCT_NAME}..." " "
nsExec::Exec 'TaskKill /FI "WINDOWTITLE eq Spyder" /F /T'
Banner::destroy
GoTo notRunning
NoClose:
Quit
notRunning:
Expand All @@ -297,20 +303,26 @@ Function validate_pre_install
MessageBox MB_YESNO|MB_ICONINFORMATION "${PRODUCT_NAME} is already installed. Uninstall the existing version?" \
/SD IDYES IDYES UninstallPreviousInstallation IDNO NoUninstall
UninstallPreviousInstallation:
Banner::show /set 76 "Please wait while uninstalling..." " "
ExecWait '"$uninstallPreviousInstallation" /S _?=$INSTDIR'
Banner::show /set 76 "Please wait while uninstalling ${PRODUCT_NAME}..." " "
CreateDirectory $TEMP\spyder-uninstaller
CopyFiles /SILENT "$uninstallPreviousInstallation" $TEMP\spyder-uninstaller\uninstall.exe
ExecWait '"$TEMP\spyder-uninstaller\uninstall.exe" /S _?=$INSTDIR'
RMDir /r $TEMP\spyder-uninstaller
Banner::destroy
${If} $0 <> 0
MessageBox MB_YESNO|MB_ICONSTOP "Failed to uninstall, continue anyway?" /SD IDYES IDYES +2
Abort
${EndIf}
StrCpy $updatingInstallation 1
Abort
GoTo NotInstalled
NoUninstall:
Quit

NotInstalled:
FunctionEnd

Function validate_updating_and_skip
${If} $updatingInstallation == 1
Abort
${EndIf}
FunctionEnd

Function .onMouseOverSection
; Find which section the mouse is over, and set the corresponding description.
FindWindow $R0 "#32770" "" $HWNDPARENT
Expand Down

0 comments on commit c9fc275

Please sign in to comment.