]> git.lyx.org Git - features.git/commitdiff
Wininstaller2: silently uninstall old LyX if not the same minor version
authorEugene Chornyi <yu_jin@lyx.org>
Fri, 11 Dec 2020 21:15:02 +0000 (22:15 +0100)
committerEugene Chornyi <yu_jin@lyx.org>
Fri, 11 Dec 2020 21:15:02 +0000 (22:15 +0100)
development/Win32/packaging/installer2/src/main.nsh

index 410910db0e5b80512b8e198980582de38dca618b..4bec8ac3067335935ed39d15c188816c0e91bf59 100644 (file)
@@ -522,6 +522,17 @@ Section -CheckSilent # This section checks if it's a silent install and calls ne
   Call DefaultDesktopFileAssoc
 SectionEnd
 
+Section -UninstallOld
+  ${If} ${FileExists} "$INSTDIR\Uninstall-LyX.exe"
+    ${GetFileVersion} "$INSTDIR\Uninstall-LyX.exe" $0
+    StrCpy $0 $0 3 # get only the first 3 chars, e.g. "2.3"
+    ${If} $0 != "${VERSION_MAJOR}.${VERSION_MINOR}"
+      ExecWait "$INSTDIR\Uninstall-LyX.exe /S _?=$INSTDIR" # silently uninstall old LyX
+      Delete "$INSTDIR\Uninstall-LyX.exe"
+    ${EndIf}
+  ${EndIf}
+SectionEnd
+
 Section -OverInstallReg # If over-installing, we need to delete the registry keys written by the previous installment
   Call PrepareShellCTX # Helper function from above
   StrCpy $1 0