PDA

View Full Version : QProcess and Vista UAC



sharevari
16th April 2007, 11:41
Has anyone got any experience with using QProcess to launch secondary processes under Vista?

Our app uses QProcess to manage the launching of some installer executables on Windows. I was hoping that it would be possible to run the app as a standard user, and then at the point of launching the installer, have Vista pop up the UAC elevation dialog so that the program can continue. However, this isn't working. The installer launch just fails with Access Denied.

The installer exe does have the correct manifest embedded which specifies that it needs administrator rights to run.

Thanks.

marcel
16th April 2007, 11:47
Vista won't launch the UAC elevation dlg automatically. You'll have to tell it in the application manifest.

Check the attached file. I downloaded it from Microsoft some time ago( Vista fever ).

marcel
16th April 2007, 11:50
Also check this out. It's not mine, I got it from codeproject. I never used it but it may be of some help to you.

Here's the link too: http://www.codeproject.com/useritems/VistaElevator.asp

sharevari
16th April 2007, 14:18
Thanks for your answer. I have been through the voluminous MS documentation on the subject and I have embedded the correct manifest requesting admin privileges.

However, the second link you posted was really useful! I didn't know about the "runas" parameter to ShellExecuteEx. So now I guess the question is whether it's possible to get that behaviour through QProcess or whether I have to drop down to a platform-specific ShellExecuteEx at this point?

marcel
16th April 2007, 14:25
However, the second link you posted was really useful! I didn't know about the "runas" parameter to ShellExecuteEx. So now I guess the question is whether it's possible to get that behaviour through QProcess or whether I have to drop down to a platform-specific ShellExecuteEx at this point?

You'll have to use ShellExecuteEx. QProcess is more generic and it does not provide the details of ShellExecuteEx. At least in 4.2.2 - 4.2.3 it doesn't.

Maybe in 4.3. I didn't get the chance to take a look at 4.3 yet.

Is your app meant to run on Mac or Linux also? Because if it is, you'll have to use QProcess for Linux/Mac and the Win API on Windows.

regards

sharevari
16th April 2007, 15:20
Actually, I just tried it and it seems I don't even have to use "runas" with ShellExecute. "open" is enough, presumably because I've already embedded a manifest requesting elevation. That makes me wonder why launching it through QProcess doesn't display the elevation dialog too...

marcel
16th April 2007, 15:28
because QProcess uses CreateProcessW.