Run desktop program with administration privileges on Windows platform
Unsolved
General and Desktop
-
Hello comunity.
There is a way to set up by code that a Qt application (a program wrote with Qt) lunch with administration privileges?
I mens, when it runs for first time Windows ask the user that this program will need privilges administration.
Thanks in advance.
-
You need to embed a manifest file to request to desired rights. There is a lot of help when searching for 'uac manifest' in the net.
The Linker command for msvc is described here: https://msdn.microsoft.com/de-de/library/bb384691.aspx -
Getting the right amount of escape characters for this in qmake is a bit tricky, so here's a code snippet you can copy/paste to your .pro file:
QMAKE_LFLAGS_WINDOWS += /MANIFESTUAC:"level='requireAdministrator'"
Don't forget to re-run qmake after that (Build->Run qmake).