From 1ec719ecdfb865bbe53309a23717041de77945b1 Mon Sep 17 00:00:00 2001 From: scorpio810 Date: Wed, 12 Aug 2015 02:57:17 +0000 Subject: [PATCH] Nsis Installers : Auto-uninstall old version before installing new version! git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4105 bfdf4180-ca20-0410-9c96-a3a8aa849046 --- packaging/windows/QET.nsi | 27 ++++++++++++++++++++++++++- packaging/windows/QET64.nsi | 26 ++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/packaging/windows/QET.nsi b/packaging/windows/QET.nsi index 4aba8a709..b6ea0ec3d 100644 --- a/packaging/windows/QET.nsi +++ b/packaging/windows/QET.nsi @@ -222,7 +222,6 @@ Section "" WriteINIStr "$SMPROGRAMS\${SOFT_NAME}\Upgrade\Download.url" "InternetShortcut" "URL" "http://download.tuxfamily.org/qet/builds/" ;changing $INSTDIR\elements\ *.elmt to read-only attribute - ${Locate} "$INSTDIR\elements\" "/L=FD /M=*.elmt" "LocateCallback" IfErrors 0 +2 MessageBox MB_OK "Error" @@ -238,6 +237,32 @@ FunctionEnd Function .onInit !insertmacro MUI_LANGDLL_DISPLAY + +;Auto-uninstall old before installing new + ReadRegStr $R0 HKLM \ + "Software\Microsoft\Windows\CurrentVersion\Uninstall\${SOFT_NAME}" \ + "UninstallString" + StrCmp $R0 "" done + + MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \ + "${SOFT_NAME} is already installed. $\n$\nClick `OK` to remove the \ + previous version or `Cancel` to cancel this upgrade." \ + IDOK uninst + Abort + +;Run the uninstaller +uninst: + ClearErrors + ExecWait '$R0 _?=$INSTDIR' ;Do not copy the uninstaller to a temp file + + IfErrors no_remove_uninstaller done + ;You can either use Delete /REBOOTOK in the uninstaller or add some code + ;here to remove the uninstaller. Use a registry key to check + ;whether the user has chosen to uninstall. If you are using an uninstaller + ;components page, make sure all sections are uninstalled. + no_remove_uninstaller: + +done: FunctionEnd diff --git a/packaging/windows/QET64.nsi b/packaging/windows/QET64.nsi index 827314a48..4c0b33d7c 100644 --- a/packaging/windows/QET64.nsi +++ b/packaging/windows/QET64.nsi @@ -256,6 +256,32 @@ ${Else} ${EndIf} !insertmacro MUI_LANGDLL_DISPLAY +;Auto-uninstall old before installing new + ReadRegStr $R0 HKLM \ + "Software\Microsoft\Windows\CurrentVersion\Uninstall\${SOFT_NAME}" \ + "UninstallString" + StrCmp $R0 "" done + + MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \ + "${SOFT_NAME} is already installed. $\n$\nClick `OK` to remove the \ + previous version or `Cancel` to cancel this upgrade." \ + IDOK uninst + Abort + +;Run the uninstaller +uninst: + ClearErrors + ExecWait '$R0 _?=$INSTDIR' ;Do not copy the uninstaller to a temp file + + IfErrors no_remove_uninstaller done + ;You can either use Delete /REBOOTOK in the uninstaller or add some code + ;here to remove the uninstaller. Use a registry key to check + ;whether the user has chosen to uninstall. If you are using an uninstaller + ;components page, make sure all sections are uninstalled. + no_remove_uninstaller: + +done: + FunctionEnd ;--------------------------------