fix: windows uninstall before re-install
authorRobin Gareus <robin@gareus.org>
Fri, 3 Apr 2015 14:45:19 +0000 (16:45 +0200)
committerRobin Gareus <robin@gareus.org>
Fri, 3 Apr 2015 15:07:25 +0000 (17:07 +0200)
tools/x-win/package.sh

index 221a07bba4df56bf5a788df13241bf1609568be5..ee1aeea319c50fdddf2a6c1af6c335b65fe9b9d7 100755 (executable)
@@ -329,14 +329,29 @@ Function .onInit
   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." \
+    "${PROGRAM_NAME} is already installed. Click 'OK' to remove the previous version or 'Cancel' to cancel this upgrade." \
     IDOK uninst
     Abort
 
   uninst:
-  ClearErrors
-  Exec \$INSTDIR\uninst.exe ;
+    ClearErrors
+    ExecWait '\$R0 _?=\$INSTDIR'
+    IfErrors uninstall_error
+
+    ReadRegStr \$R1 HKLM \
+      "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${PRODUCT_ID}" \
+      "UninstallString"
+    StrCmp \$R1 "" 0 done
+
+    Delete "\$INSTDIR\\uninstall.exe"
+    RMDir "\$INSTDIR"
+    goto done
+
+  uninstall_error:
+
+    MessageBox MB_OK|MB_ICONEXCLAMATION \
+      "Uninstaller did not complete successfully. Continue at your own risk..." \
+      IDOK done
 
   done: