QProcess with Elevated permission
-
Hello experts,
Need a helping hand here..I am running a thridparty exe using QProcess ( in windows platform ) from my c++ code, and in tern windows automatically ask the user for elevated-permission and the user can either Allow or deny the permission to run the process.
How can I detect, if the user has pressed Deny?
( I have tried different signals to get the exit-code/state/erroroccured, but nothing works so far.. fyi, the state shows as "running" even though user denies the permission)Thanks in advance
Hrishi -
Hello experts,
Need a helping hand here..I am running a thridparty exe using QProcess ( in windows platform ) from my c++ code, and in tern windows automatically ask the user for elevated-permission and the user can either Allow or deny the permission to run the process.
How can I detect, if the user has pressed Deny?
( I have tried different signals to get the exit-code/state/erroroccured, but nothing works so far.. fyi, the state shows as "running" even though user denies the permission)Thanks in advance
Hrishi@HrishiGobler
If the user selects Deny I would expect the OS command to be terminated/not to run. There might not be a signal, I don't know. [I don't run Qt under Windows.]If you claim that once the user has clicked Deny the command "continues" to run and does not change state that would sound "bad". It would mean the command will never complete, one way or the other. I find that hard to believe. It is possible that
QProcess
code might not get the state right, I guess; but look at Task Manager, what is actually going on for the sub-process? -
@HrishiGobler
If the user selects Deny I would expect the OS command to be terminated/not to run. There might not be a signal, I don't know. [I don't run Qt under Windows.]If you claim that once the user has clicked Deny the command "continues" to run and does not change state that would sound "bad". It would mean the command will never complete, one way or the other. I find that hard to believe. It is possible that
QProcess
code might not get the state right, I guess; but look at Task Manager, what is actually going on for the sub-process?@JonB Thanks for taking a look on this.
FYI, the actual process(Notepad.exe) has never started ( as the user presses Deny), I have made sure this from "Task manager" that the process(Notepad.exe) has never started.
But still, the started() method QProcess returns true. -
@JonB Thanks for taking a look on this.
FYI, the actual process(Notepad.exe) has never started ( as the user presses Deny), I have made sure this from "Task manager" that the process(Notepad.exe) has never started.
But still, the started() method QProcess returns true.@HrishiGobler
OK. But the issue here is that you claim that afterQProcess::started()
the process is "stuck" on "Running" and never "finishes" after the user clicks Deny. If that is true it is problematic.You could Google for
qprocess uac
. There are a few hits, but mostly about how you might run elevated not your Deny report. (Nonetheless, some of the advice there about6 running it via Windows shell might be of interest.)You might also try running your command via
QProcess::start("cmd", { "-c", yourCommand } )
to see if that finishes.I doubt anything is going to tell you about Deny having been selected. Certainly not from
QProcess
. The native WindowsShellExecute()
-type calls might do.If it is really true that the
QProcess
never sees the process as having finished you might (first search and then) report it as a Qt bug to see whether the devs have anything to say.