changeset 594:c944de9900de

Add installation parameters with correct quoting
author Andre Heinecke <aheinecke@intevation.de>
date Wed, 28 May 2014 08:55:53 +0000
parents d0e7a80a11fe
children 2c4eb4435a40
files ui/mainwindow.cpp ui/mainwindow.h
diffstat 2 files changed, 16 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/ui/mainwindow.cpp	Wed May 28 12:16:36 2014 +0200
+++ b/ui/mainwindow.cpp	Wed May 28 08:55:53 2014 +0000
@@ -244,13 +244,18 @@
     QDir installDir = fi.absoluteDir();
 
 #ifdef WIN32
+    QString parameters = QString::fromLatin1("/S /UPDATE=1 /D=") +
+        installDir.path().replace("/", "\\") + "";
+
     SHELLEXECUTEINFOW shExecInfo;
     memset (&shExecInfo, 0, sizeof(SHELLEXECUTEINFOW));
     shExecInfo.cbSize = sizeof(SHELLEXECUTEINFOW);
 
     shExecInfo.lpFile = reinterpret_cast<LPCWSTR> (filePath.utf16());
+    shExecInfo.lpParameters = reinterpret_cast<LPCWSTR> (parameters.utf16());
 
-    shExecInfo.fMask = SEE_MASK_NOASYNC;
+  //  shExecInfo.fMask = SEE_MASK_NOASYNC;
+    shExecInfo.nShow = SW_SHOWDEFAULT;
 
     if (!is_admin()) {
         shExecInfo.lpVerb = L"open";
@@ -258,7 +263,8 @@
         shExecInfo.lpVerb = L"runas";
     }
 
-    qDebug() << "Starting process: " << filePath;
+    qDebug() << "Starting process: " << filePath
+             << " with arguments: " << parameters;
 
     if (!ShellExecuteExW(&shExecInfo)) {
         /* Execution failed, maybe the user aborted the UAC check? */
@@ -270,9 +276,13 @@
         return;
     }
 #else /* WIN32 */
-    qDebug() << "Starting process " << filePath;
+    QStringList parameters;
+    parameters << "/S" << "/UPDATE=1"
+               << QString::fromLatin1("/D=%1").arg(installDir.path());
 
-    if (!QProcess::startDetached(filePath)) {
+    qDebug() << "Starting process " << filePath << " args: " << parameters;
+
+    if (!QProcess::startDetached(filePath, parameters)) {
         qDebug() << "Failed to start process.";
         return;
     }
--- a/ui/mainwindow.h	Wed May 28 12:16:36 2014 +0200
+++ b/ui/mainwindow.h	Wed May 28 08:55:53 2014 +0000
@@ -136,7 +136,7 @@
 private:
     /** @brief check the integrity of available certificate lists.
      *
-     * Note: Do not use this as a trust check as this only works on
+     * Note: Do not use this as a local trust check as this only works on
      * FileNames where the underlying files can change. This
      * is just meant to check if the downloaded data was somehow
      * removed or corrupted. It also initializes mListToInstall
@@ -146,7 +146,7 @@
 
     /** @brief check the integrity of available software updates.
      *
-     * Note: Do not use this as a trust check as this only works on
+     * Note: Do not use this as a local trust check as this only works on
      * FileNames where the underlying files can change. This
      * is just meant to check if the downloaded data was somehow
      * removed or corrupted.

http://wald.intevation.org/projects/trustbridge/