QProcess::startDetached and UAC on Vista
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.
Re: QProcess::startDetached and UAC on Vista
Re: QProcess::startDetached and UAC on Vista
Go thru this post http://codeblog.vurdalakov.net/2010/...ed-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