2

I have a Qt 5.11 application that's being compiled for Windows and includes an application manifest that instructs Windows to run the application with Administrator privileges.

...
<requestedPrivileges>
  <requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
</requestedPrivileges>
...

This run level is necessary for normal functioning of the program, as it's mostly a utility application to manage the installations of other programs (ie, the Program Files directory).

However, I am starting a detached process from within this application. I would like to start this application as a normal user-level application, not with Administrator permissions (for a couple reasons, including the fact that the child application does not handle running with Administrator permissions well).

Some things that I've tried:

  • Running the main application as user-level.
    • Executing some of the processes as user-level is not a problem
    • Other processes need to be executed as Administrator level. Trying to open an application that requires those higher-level privileges simply causes the QProcess:startDetached() to fail.
  • Running the main application as Administrator-level
    • Executing some of the processes as user-level is what I'm trying to accomplish
    • Running the other processes as Administrator is not an issue.

Related question (without an answer): QT Start program as regular user

  • Use https://en.wikipedia.org/wiki/Runas ? – hyde Aug 15 '18 at 21:04
  • 1
    Thanks for the suggestion, but it does not work. Running with the `"runas /trustlevel:0x20000 \"myprogram.exe /myflag\""` even from an Administrator command prompt still runs the program with administrator privileges. Same as launching it with the `QProcess::startDetached". – Justin McBride Aug 16 '18 at 17:28
  • Maybe ask at superuser.com or similar place, if you can reproduce the problem from command prompt without programming. – hyde Aug 21 '18 at 11:43
  • This sounds backwards. Normally the program should run as standard user, and elevate a process only when elevation is required. If you require some process to run as administrator, one solution is to create a service. – Bill_Stewart Aug 24 '18 at 18:45
  • @Bill_Stewart -- it's a fair point, but I feel that this is appropriate. Most of the application's functions actually do require administrator privileges to perform their tasks properly. It's simply that another aspect of the same application is to spawn a detached child process, and this child does not (and should not to function properly) have those same permissions. One suggestion that I've seen for installer binaries is to spawn two instances of the program: the first as normal privileges with no window, and a higher process with the GUI. Then, you can delegate back the launching. – Justin McBride Aug 27 '18 at 16:31

0 Answers0