[qet] [4105] Nsis Installers : Auto-uninstall old version before installing new version!

[ Thread Index | Date Index | More lists.tuxfamily.org/qet Archives ]


Revision: 4105
Author:   scorpio810
Date:     2015-08-12 04:57:17 +0200 (Wed, 12 Aug 2015)
Log Message:
-----------
Nsis Installers : Auto-uninstall old version before installing new version!

Modified Paths:
--------------
    trunk/packaging/windows/QET.nsi
    trunk/packaging/windows/QET64.nsi

Modified: trunk/packaging/windows/QET.nsi
===================================================================
--- trunk/packaging/windows/QET.nsi	2015-08-12 00:39:02 UTC (rev 4104)
+++ trunk/packaging/windows/QET.nsi	2015-08-12 02:57:17 UTC (rev 4105)
@@ -222,7 +222,6 @@
 	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 @@
 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
 

Modified: trunk/packaging/windows/QET64.nsi
===================================================================
--- trunk/packaging/windows/QET64.nsi	2015-08-12 00:39:02 UTC (rev 4104)
+++ trunk/packaging/windows/QET64.nsi	2015-08-12 02:57:17 UTC (rev 4105)
@@ -256,6 +256,32 @@
 ${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
 
 ;--------------------------------


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/