Qt (on Windows) sets the privilege level to "requireAdministrator"

I am using Qt Creator and trying to make the file .exerun by default as an administrator.

After reading all the solutions online, I tried to put this line in my file .pro:

QMAKE_LFLAGS += /MANIFESTUAC:"level='requireAdministrator' uiAccess='false'"

But still, when I check my .exe(using notepad), it contains:

<requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel>

Can someone tell me how to add requireAdministrator?

Workaround: Until now, I could not find a solution, so I made a temporary hack. I made .exe "LaunchAnother.exe" that will launch my "main.exe" using the following code:

SHELLEXECUTEINFO shExInfo = {0};
shExInfo.cbSize = sizeof(shExInfo);
shExInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
shExInfo.hwnd = 0;
shExInfo.lpVerb = _T("runas");                // Operation to perform
shExInfo.lpFile = _T("main.exe");       // Application to start    
shExInfo.lpParameters = "";                  // Additional parameters
shExInfo.lpDirectory = 0;
shExInfo.nShow = SW_SHOW;
shExInfo.hInstApp = 0;  

if (ShellExecuteEx(&shExInfo))
{
    WaitForSingleObject(shExInfo.hProcess, INFINITE);
    CloseHandle(shExInfo.hProcess);
}

Still waiting for a better solution.

+5
source share
1 answer

mt.exe.

(UAC)

C/++

- .res , :

dll mingw

, .

+2

All Articles