windows: run uninstaller on re-install
authorRobin Gareus <robin@gareus.org>
Thu, 2 Apr 2015 16:56:38 +0000 (18:56 +0200)
committerRobin Gareus <robin@gareus.org>
Thu, 2 Apr 2015 16:56:38 +0000 (18:56 +0200)
tools/x-win/package.sh

index ecc588b55be3dc00e872da4b347e5544ead25439..610830f934817ab765f54d7f3e62d75ab6eb0743 100755 (executable)
@@ -320,6 +320,29 @@ cat >> $NSISFILE << EOF
 !insertmacro MUI_UNPAGE_INSTFILES
 !insertmacro MUI_LANGUAGE "English"
 
+
+Function .onInit
+
+  ReadRegStr \$R0 HKLM \
+    "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${PRODUCT_ID}" \
+    "UninstallString"
+  StrCmp \$R0 "" done
+
+  MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \
+    "${PROGRAM_NAME} is already installed. \$\\n\$\\nClick 'OK' to remove the \
+    previous version or 'Cancel' to cancel this upgrade." \
+    IDOK uninst
+    Abort
+
+  uninst:
+  ClearErrors
+  Exec \$INSTDIR\uninst.exe ;
+
+  done:
+
+FunctionEnd
+
+
 Section "${PROGRAM_NAME}${PROGRAM_VERSION} (required)" SecMainProg
   SectionIn RO
   SetOutPath \$INSTDIR