Ask to uninstall old versions on upgrade
authorSean Engelhardt <sean.engelhardt@intevation.de>
Tue, 8 Dec 2015 14:12:01 +0000 (15:12 +0100)
committerAndre Heinecke <aheinecke@intevation.de>
Tue, 8 Dec 2015 14:34:54 +0000 (15:34 +0100)
* src/installer.nsi (CheckExistingVersion): Ask to uninstall
 old version.

--
If an other version was detected, the user will receive an
accordingly information. If the user chooses to proceed the
installation, the uninstaller of the old version will be executed.

Commit message amended by Andre Heinecke <aheinecke@intevation.de>

src/installer.nsi

index 88a735e..865e6bf 100644 (file)
@@ -398,8 +398,17 @@ Function CheckExistingVersion
   ClearErrors
   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\GPG4Win" "DisplayVersion"
   IfErrors leave 0
-     MessageBox MB_YESNO "$(T_FoundExistingVersionB)" IDYES leave
-     Abort
+     StrCmp $0 ${VERSION} sameversion otherversion
+     otherversion:
+       MessageBox MB_YESNO "$(T_FoundExistingOldVersion)" IDYES uninstall
+       Abort
+     sameversion:
+       MessageBox MB_YESNO "$(T_FoundExistingVersionB)" IDYES leave
+       Abort
+
+ uninstall:
+  ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\GPG4Win" "UninstallString"
+  ExecWait '$0 /S'
 
  # TODO This is the normal update case. Handle more gracefully.
  # Especially the install path change from 2.x to 3.x