Mercurial > trustbridge
comparison 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 |
comparison
equal
deleted
inserted
replaced
593:d0e7a80a11fe | 594:c944de9900de |
---|---|
242 } | 242 } |
243 QFileInfo fi(QCoreApplication::applicationFilePath()); | 243 QFileInfo fi(QCoreApplication::applicationFilePath()); |
244 QDir installDir = fi.absoluteDir(); | 244 QDir installDir = fi.absoluteDir(); |
245 | 245 |
246 #ifdef WIN32 | 246 #ifdef WIN32 |
247 QString parameters = QString::fromLatin1("/S /UPDATE=1 /D=") + | |
248 installDir.path().replace("/", "\\") + ""; | |
249 | |
247 SHELLEXECUTEINFOW shExecInfo; | 250 SHELLEXECUTEINFOW shExecInfo; |
248 memset (&shExecInfo, 0, sizeof(SHELLEXECUTEINFOW)); | 251 memset (&shExecInfo, 0, sizeof(SHELLEXECUTEINFOW)); |
249 shExecInfo.cbSize = sizeof(SHELLEXECUTEINFOW); | 252 shExecInfo.cbSize = sizeof(SHELLEXECUTEINFOW); |
250 | 253 |
251 shExecInfo.lpFile = reinterpret_cast<LPCWSTR> (filePath.utf16()); | 254 shExecInfo.lpFile = reinterpret_cast<LPCWSTR> (filePath.utf16()); |
252 | 255 shExecInfo.lpParameters = reinterpret_cast<LPCWSTR> (parameters.utf16()); |
253 shExecInfo.fMask = SEE_MASK_NOASYNC; | 256 |
257 // shExecInfo.fMask = SEE_MASK_NOASYNC; | |
258 shExecInfo.nShow = SW_SHOWDEFAULT; | |
254 | 259 |
255 if (!is_admin()) { | 260 if (!is_admin()) { |
256 shExecInfo.lpVerb = L"open"; | 261 shExecInfo.lpVerb = L"open"; |
257 } else { | 262 } else { |
258 shExecInfo.lpVerb = L"runas"; | 263 shExecInfo.lpVerb = L"runas"; |
259 } | 264 } |
260 | 265 |
261 qDebug() << "Starting process: " << filePath; | 266 qDebug() << "Starting process: " << filePath |
267 << " with arguments: " << parameters; | |
262 | 268 |
263 if (!ShellExecuteExW(&shExecInfo)) { | 269 if (!ShellExecuteExW(&shExecInfo)) { |
264 /* Execution failed, maybe the user aborted the UAC check? */ | 270 /* Execution failed, maybe the user aborted the UAC check? */ |
265 char* errmsg = getLastErrorMsg(); | 271 char* errmsg = getLastErrorMsg(); |
266 QString qerrmsg = QString::fromUtf8(errmsg); | 272 QString qerrmsg = QString::fromUtf8(errmsg); |
268 qDebug() << "Failed to start process: " << qerrmsg; | 274 qDebug() << "Failed to start process: " << qerrmsg; |
269 setState(NewSoftwareAvailable); | 275 setState(NewSoftwareAvailable); |
270 return; | 276 return; |
271 } | 277 } |
272 #else /* WIN32 */ | 278 #else /* WIN32 */ |
273 qDebug() << "Starting process " << filePath; | 279 QStringList parameters; |
274 | 280 parameters << "/S" << "/UPDATE=1" |
275 if (!QProcess::startDetached(filePath)) { | 281 << QString::fromLatin1("/D=%1").arg(installDir.path()); |
282 | |
283 qDebug() << "Starting process " << filePath << " args: " << parameters; | |
284 | |
285 if (!QProcess::startDetached(filePath, parameters)) { | |
276 qDebug() << "Failed to start process."; | 286 qDebug() << "Failed to start process."; |
277 return; | 287 return; |
278 } | 288 } |
279 #endif | 289 #endif |
280 /* Installer process should now be running. We exit */ | 290 /* Installer process should now be running. We exit */ |