diff ui/mainwindow.cpp @ 594:c944de9900de

Add installation parameters with correct quoting
author Andre Heinecke <aheinecke@intevation.de>
date Wed, 28 May 2014 08:55:53 +0000
parents 778f74d0706f
children e83589f1fd7f
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;
     }

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