Run msi properly and restart client after update
authorDominik Schmidt <dev@dominik-schmidt.de>
Wed, 13 Jun 2018 12:06:37 +0000 (14:06 +0200)
committerCamila (Rebase PR Action) <hello@camila.codes>
Tue, 24 Nov 2020 18:22:33 +0000 (18:22 +0000)
src/gui/updater/ocupdater.cpp

index 78e7021eba5b94a7e833c18f28bbbd2edbad5b48..c88eb0cca15f94ac16b30cb43a802dbee9592349 100644 (file)
@@ -195,9 +195,18 @@ void OCUpdater::slotStartInstaller()
 
     if(updateFile.endsWith(".exe")) {
         QProcess::startDetached(updateFile, QStringList() << "/S"
-                                                        << "/launch");
-    } else {
-        QDesktopServices::openUrl(QUrl("file:///" + updateFile, QUrl::TolerantMode));
+                                                          << "/launch");
+    } else if(updateFile.endsWith(".msi")) {
+        // When MSIs are installed without gui they cannot launch applications
+        // as they lack the user context. That is why we need to run the client
+        // manually here. We wrap the msiexec and client invocation in a powershell
+        // script because owncloud.exe will be shut down for installation.
+        // | Out-Null forces powershell to wait for msiexec to finish.
+        QString command = QString("&{msiexec /norestart /passive /i '%1' | Out-Null ; &'%2'}")
+            .arg(QDir::toNativeSeparators(updateFile))
+            .arg(QDir::toNativeSeparators(QCoreApplication::applicationFilePath()));
+
+        QProcess::startDetached("powershell.exe", QStringList{"-Command", command});
     }
 }