QProcess::startDetached(): Support privilege elevation for non-.exe files

Pass classname 'exefile' to ShellExecuteEx() for UAC prompt.
This allows running executable files that do not have a .exe extension.

Task-number: QTBUG-59008
Change-Id: I88d669481e893db50edccd7b30259e5366477556
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
Stephan Reiter 2017-02-17 20:40:19 +01:00 committed by Oswald Buddenhagen
parent dab0138043
commit 1d44b6bedb

View File

@ -841,7 +841,8 @@ static bool startDetachedUacPrompt(const QString &programIn, const QStringList &
SHELLEXECUTEINFOW shellExecuteExInfo;
memset(&shellExecuteExInfo, 0, sizeof(SHELLEXECUTEINFOW));
shellExecuteExInfo.cbSize = sizeof(SHELLEXECUTEINFOW);
shellExecuteExInfo.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_UNICODE | SEE_MASK_FLAG_NO_UI;
shellExecuteExInfo.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_UNICODE | SEE_MASK_FLAG_NO_UI | SEE_MASK_CLASSNAME;
shellExecuteExInfo.lpClass = L"exefile";
shellExecuteExInfo.lpVerb = L"runas";
const QString program = QDir::toNativeSeparators(programIn);
shellExecuteExInfo.lpFile = reinterpret_cast<LPCWSTR>(program.utf16());