PDA

View Full Version : QProcess::startDetached and UAC on Vista



serious_jack
20th November 2008, 18:26
Hello.

The problem: I've got a software update issue on Windows Vista.

I try to launch the updater for this software with QProcess::startDetached() from the application before closing it.

Works perfectly on XP when the application was launched by an administrator, but on Vista running the updater requires admin rights, and if the UAC is enabled (default behaviour on Vista) the startDetached method fails.

How can I solve this ?

Thanks.

--
Jack.

caesarxx
9th February 2011, 15:31
did you find out how ?

pavanbarot
24th November 2011, 07:13
Go thru this post http://codeblog.vurdalakov.net/2010/09/solution-qprocessstartdetached-cannot.html

try below code:


#ifdef Q_OS_WIN
#include <windows.h>
#include <shellapi.h>
#endif

/.../

QString exeFileName;

/.../


#ifdef Q_OS_WIN
int result = (int)::ShellExecuteA(0, "open", exeFileName.toUtf8().constData(), 0, 0, SW_SHOWNORMAL);
if (SE_ERR_ACCESSDENIED == result)
{
// Requesting elevation
result = (int)::ShellExecuteA(0, "runas", exeFileName.toUtf8().constData(), 0, 0, SW_SHOWNORMAL);
}
if (result <= 32)
{
// error handling
}
#else
if (!QProcess::startDetached(exeFileName))
{
// error handling
}
#endif