Program requesting elevation cannot be launched through a button..

G

Guest

....with UAC on. I have an application that requests elevation through its
manifest. When launched normally, the UAC dialog shows and accepting the
dialog allows the app to run normally. But when I assign this app to a
scanner button using Scanner&Camera in the control panel, the app does not
start when the button is pressed. It doesn't even show the elevation dialog.
If I turn off UAC the button launches the app just as one would expect. If
I create a little launcher app that does not request any elevation, whose
only purpose is to launch the previously mentioned app requesting elevation,
the app launches and runs normally after displaying the UAC dialog. Does
anybody know why a scanner button cannot launch an application that is
requesting elevation if UAC is on? Any help would be greatly appreciated.
 
A

Adrian Accinelli

mchrist152 said:
...with UAC on. I have an application that requests elevation through its
manifest. When launched normally, the UAC dialog shows and accepting the
dialog allows the app to run normally. But when I assign this app to a
scanner button using Scanner&Camera in the control panel, the app does not
start when the button is pressed. It doesn't even show the elevation
dialog.
If I turn off UAC the button launches the app just as one would expect.
If
I create a little launcher app that does not request any elevation, whose
only purpose is to launch the previously mentioned app requesting
elevation,
the app launches and runs normally after displaying the UAC dialog. Does
anybody know why a scanner button cannot launch an application that is
requesting elevation if UAC is on? Any help would be greatly appreciated.

The backend code is trying to use CreateProcess instead of ShellExecute to
launch the app. This is described in various places on the net but this
link contains information on it:
http://msdn2.microsoft.com/en-us/library/aa905330.aspx

There's a nice description of how ShellExecute works and you'll see
CreateProcess is called and fails and doing so then calls into the
Application Information Service to perform the launch/prompt. With UAC
turned off CreateProcess will succeed so that's why it works in this
situation.

You should mark your app asInvoker and if you detect you need privileges
restart yourself using ShellExecute/Runas so that you will become elevated.

Sincerely,
Adrian Accinelli
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top