summaryrefslogtreecommitdiffstats
path: root/Modules/NSIS.template.in
diff options
context:
space:
mode:
authorDavid Cole <david.cole@kitware.com>2012-04-25 18:06:29 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2012-04-25 18:06:29 (GMT)
commit419f561b2f554b0fd92482c79ba49be0e3f7875e (patch)
tree82ec3cee8349065ad79bd664d73844d2f2680cf1 /Modules/NSIS.template.in
parent4b4a98d72298e892b17aa0d14462bab7836a7c1d (diff)
parentfe58b67e24d007cb7dcd7005073a37bfba21737d (diff)
downloadCMake-419f561b2f554b0fd92482c79ba49be0e3f7875e.zip
CMake-419f561b2f554b0fd92482c79ba49be0e3f7875e.tar.gz
CMake-419f561b2f554b0fd92482c79ba49be0e3f7875e.tar.bz2
Merge topic 'fix-9946-uninstall-before-install'
fe58b67 Added CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL
Diffstat (limited to 'Modules/NSIS.template.in')
-rw-r--r--Modules/NSIS.template.in22
1 files changed, 22 insertions, 0 deletions
diff --git a/Modules/NSIS.template.in b/Modules/NSIS.template.in
index e7edead..43f72f6 100644
--- a/Modules/NSIS.template.in
+++ b/Modules/NSIS.template.in
@@ -900,6 +900,28 @@ SectionEnd
; "Program Files" for AllUsers, "My Documents" for JustMe...
Function .onInit
+ StrCmp "@CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL@" "ON" 0 inst
+
+ ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_NAME@" "UninstallString"
+ StrCmp $0 "" inst
+
+ MessageBox MB_YESNOCANCEL|MB_ICONEXCLAMATION \
+ "@CPACK_NSIS_PACKAGE_NAME@ is already installed. $\n$\nDo you want to uninstall the old version before installing the new one?" \
+ IDYES uninst IDNO inst
+ Abort
+
+;Run the uninstaller
+uninst:
+ ClearErrors
+ ExecWait '$0 _?=$INSTDIR' ;Do not copy the uninstaller to a temp file
+
+ IfErrors uninst_failed inst
+uninst_failed:
+ MessageBox MB_OK|MB_ICONSTOP "Uninstall failed."
+ Abort
+
+
+inst:
; Reads components status for registry
!insertmacro SectionList "InitSection"