Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - Vista UAC - get app to request escalation for a task

Reply
 
Old 07-28-2008   #1 (permalink)
d-42


 
 

Vista UAC - get app to request escalation for a task

Hi,

How do I ask for escalation from within a program?

I'm developing a standalone program that can also act as a 'plugin' to
another application. The way the other app was designed, it scans a
plugin folder in its "program files" folder for settings documents
which contain all the settings it needs to know to call the plug-in
apps.

The problem, of course, is permissions. Under vista, even the
administrator accounts are prevented from writing to the folder
without escalation.

So I how do I request escalation so that my program can save the
settings file to its plugin folder? right now it just throws an
exception 'access denied'. I'd be happy if I could get the 'The
program is trying to access a protected folder..." type of message
that they could just accept. After all, it only normally needs to be
done once.

As it stands now, it works if they launch the software using the 'run
as administrator', but I'd prefer it to ask on that one function
instead, if its not a buttload of work.

thanks in advance for any suggestions or advice,
-Dave

My System SpecsSystem Spec
Old 07-28-2008   #2 (permalink)
Mr. Arnold


 
 

Re: Vista UAC - get app to request escalation for a task


"d-42" <db.porsche@xxxxxx> wrote in message
news:d96453ab-3bb5-4933-848e-0313bcc69111@xxxxxx
Quote:

> Hi,
>
> How do I ask for escalation from within a program?
>
> I'm developing a standalone program that can also act as a 'plugin' to
> another application. The way the other app was designed, it scans a
> plugin folder in its "program files" folder for settings documents
> which contain all the settings it needs to know to call the plug-in
> apps.
>
> The problem, of course, is permissions. Under vista, even the
> administrator accounts are prevented from writing to the folder
> without escalation.
>
> So I how do I request escalation so that my program can save the
> settings file to its plugin folder? right now it just throws an
> exception 'access denied'. I'd be happy if I could get the 'The
> program is trying to access a protected folder..." type of message
> that they could just accept. After all, it only normally needs to be
> done once.
>
> As it stands now, it works if they launch the software using the 'run
> as administrator', but I'd prefer it to ask on that one function
> instead, if its not a buttload of work.
>
Your program would use the Vista UAC manifest to provide the needed
credentials during program runtime, look it up use Google.

My System SpecsSystem Spec
Old 07-29-2008   #3 (permalink)
d-42


 
 

Re: Vista UAC - get app to request escalation for a task

On Jul 28, 8:56*pm, "Mr. Arnold" <MR. Arn...@xxxxxx> wrote:
Quote:

> "d-42" <db.pors...@xxxxxx> wrote in message
>
> news:d96453ab-3bb5-4933-848e-0313bcc69111@xxxxxx
>
>
>
Quote:

> > Hi,
>
Quote:

> > How do I ask for escalation from within a program?
>
Quote:

> > I'm developing a standalone program that can also act as a 'plugin' to
> > another application. The way the other app was designed, it scans a
> > plugin folder in its "program files" folder for settings documents
> > which contain all the settings it needs to know to call the plug-in
> > apps.
>
Quote:

> > The problem, of course, is permissions. Under vista, even the
> > administrator accounts are prevented from writing to the folder
> > without escalation.
>
Quote:

> > So I how do I request escalation so that my program can save the
> > settings file to its plugin folder? right now it just throws an
> > exception 'access denied'. I'd be happy if I could get the 'The
> > program is trying to access a protected folder..." type of message
> > that they could just accept. After all, it only normally needs to be
> > done once.
>
Quote:

> > As it stands now, it works if they launch the software using the 'run
> > as administrator', but I'd prefer it to ask on that one function
> > instead, if its not a buttload of work.
>
> Your program would use the Vista UAC manifest to provide the needed
> credentials during program runtime, look it up use Google.
But I don't want the entire program need escalation, just the one
rarely used feature. I take it that's not possible? That I have to
spin-off the feature into its own executable, and provide a separate
manifest requiring escalation for that?

-regards,
Dave
My System SpecsSystem Spec
Old 07-30-2008   #4 (permalink)
Mr. Arnold


 
 

Re: Vista UAC - get app to request escalation for a task


"d-42" <db.porsche@xxxxxx> wrote in message
news:3c50031e-9ef4-4476-bf14-51054ec3fa4d@xxxxxx
On Jul 28, 8:56 pm, "Mr. Arnold" <MR. Arn...@xxxxxx> wrote:
Quote:

> "d-42" <db.pors...@xxxxxx> wrote in message
>
> news:d96453ab-3bb5-4933-848e-0313bcc69111@xxxxxx
>
>
>
Quote:

> > Hi,
>
Quote:

> > How do I ask for escalation from within a program?
>
Quote:

> > I'm developing a standalone program that can also act as a 'plugin' to
> > another application. The way the other app was designed, it scans a
> > plugin folder in its "program files" folder for settings documents
> > which contain all the settings it needs to know to call the plug-in
> > apps.
>
Quote:

> > The problem, of course, is permissions. Under vista, even the
> > administrator accounts are prevented from writing to the folder
> > without escalation.
>
Quote:

> > So I how do I request escalation so that my program can save the
> > settings file to its plugin folder? right now it just throws an
> > exception 'access denied'. I'd be happy if I could get the 'The
> > program is trying to access a protected folder..." type of message
> > that they could just accept. After all, it only normally needs to be
> > done once.
>
Quote:

> > As it stands now, it works if they launch the software using the 'run
> > as administrator', but I'd prefer it to ask on that one function
> > instead, if its not a buttload of work.
>
> Your program would use the Vista UAC manifest to provide the needed
> credentials during program runtime, look it up use Google.
But I don't want the entire program need escalation, just the one
rarely used feature. I take it that's not possible? That I have to
spin-off the feature into its own executable, and provide a separate
manifest requiring escalation for that?

<http://news.softpedia.com/news/Admin-Approval-Mode-in-Windows-Vista-45312.shtml>

<http://www.computerperformance.co.uk/vista/vista_administrator_activate.htm#Summary_of_Vista_Administrator_-_Super_User_(Hidden_Account)>

<http://www.codeproject.com/KB/vista-security/MakingAppsUACAware.aspx>

My System SpecsSystem Spec
Old 07-30-2008   #5 (permalink)
Markus Mayer


 
 

UAC: Elevate process only when needed, was: Vista UAC - get app torequest escalation for a task

>> > How do I ask for escalation from within a program?
Quote:
Quote:

>>
>> Your program would use the Vista UAC manifest to provide the needed
>> credentials during program runtime, look it up use Google.
>
> But I don't want the entire program need escalation, just the one
> rarely used feature. I take it that's not possible? That I have to
> spin-off the feature into its own executable, and provide a separate
> manifest requiring escalation for that?
>
Same problem here. I'm trying to write an auto updater that (obviously)
needs to write to the "program files" folder. When I set the manifest's
requestedExecutionLevel to requireAdministrator the application can
write there, but with the massive drawback that the user is prompted to
allow the application as soon as it starts.

What I need is that the program only asks for elevation when needed -
that is, if, and only if, it needs to write to "program files".
Any idea how to accomplish that?
(Didn't find any clue in the links provided)

Markus
My System SpecsSystem Spec
Old 07-30-2008   #6 (permalink)
Markus Mayer


 
 

Re: UAC: Elevate process only when needed, was: Vista UAC - get appto request escalation for a task

Markus Mayer schrieb:
Quote:
Quote:
Quote:

>>>> How do I ask for escalation from within a program?
>>> Your program would use the Vista UAC manifest to provide the needed
>>> credentials during program runtime, look it up use Google.
>> But I don't want the entire program need escalation, just the one
>> rarely used feature. I take it that's not possible? That I have to
>> spin-off the feature into its own executable, and provide a separate
>> manifest requiring escalation for that?
>>
>
> What I need is that the program only asks for elevation when needed -
> that is, if, and only if, it needs to write to "program files".
> Any idea how to accomplish that?
> (Didn't find any clue in the links provided)
Hm. I obviously missed the part saying "This is the only time
applications can do this as applications cannot change their level later
and decide to elevate once running".
Doesn't solve the problem, though. What's the magic of these "shield"
buttons? Do they simply call an executable with a "run as administrator"
constraint?

Markus
My System SpecsSystem Spec
Old 07-30-2008   #7 (permalink)
d-42


 
 

Re: UAC: Elevate process only when needed, was: Vista UAC - get appto request escalation for a task

On Jul 30, 3:30*am, Markus Mayer
<_nospam_usenet_nospam_@_nospam_defx_nospam_.de> wrote:
Quote:

> Markus Mayer schrieb:
>
Quote:
Quote:

> >>>> How do I ask for escalation from within a program?
> >>> Your program would use the Vista UAC manifest to provide the needed
> >>> credentials during program runtime, look it up use Google.
> >> But I don't want the entire program need escalation, just the one
> >> rarely used feature. I take it that's not possible? That I have to
> >> spin-off the feature into its own executable, and provide a separate
> >> manifest requiring escalation for that?
>
Quote:

> > What I need is that the program only asks for elevation when needed -
> > that is, if, and only if, it needs to write to "program files".
> > Any idea how to accomplish that?
> > (Didn't find any clue in the links provided)
>
> Hm. I obviously missed the part saying "This is the only time
> applications can do this as applications cannot change their level later
> and decide to elevate once running".
> Doesn't solve the problem, though. What's the magic of these "shield"
> buttons? Do they simply call an executable with a "run as administrator"
> constraint?
>
> Markus
Based on what I (we have both) read at the codeproject article, it
looks like the process has to be terminated and restarted to get
higher priv's... so I suppose instead of a separate executable, the
menu-item could call the same executable with a 'run as administrator'
and a suitable command line parameter to invoke the feature.

But that's still bloody ugly in my case, since it means the entire
state of the app has to be persisted and restored, to make it
"seamless". For my situation, having it spawn a separate escalated
process to install the plugin file, seems to be the best solution. For
your situation i'd speculate that since you are doing an upgrade, a
terminate and restart as a administrator with command line option to
perform the upgrade is probably acceptable.

cheers,
Dave
My System SpecsSystem Spec
Old 07-30-2008   #8 (permalink)
d-42


 
 

Re: UAC: Elevate process only when needed, was: Vista UAC - get appto request escalation for a task

On Jul 30, 3:30*am, Markus Mayer
<_nospam_usenet_nospam_@_nospam_defx_nospam_.de> wrote:
Quote:

> Markus Mayer schrieb:
>
Quote:
Quote:

> >>>> How do I ask for escalation from within a program?
> >>> Your program would use the Vista UAC manifest to provide the needed
> >>> credentials during program runtime, look it up use Google.
> >> But I don't want the entire program need escalation, just the one
> >> rarely used feature. I take it that's not possible? That I have to
> >> spin-off the feature into its own executable, and provide a separate
> >> manifest requiring escalation for that?
>
Quote:

> > What I need is that the program only asks for elevation when needed -
> > that is, if, and only if, it needs to write to "program files".
> > Any idea how to accomplish that?
> > (Didn't find any clue in the links provided)
>
> Hm. I obviously missed the part saying "This is the only time
> applications can do this as applications cannot change their level later
> and decide to elevate once running".
> Doesn't solve the problem, though. What's the magic of these "shield"
> buttons? Do they simply call an executable with a "run as administrator"
> constraint?
>
> Markus
In follow up I also found this article which is quite informative, and
really, more applicable than the other links we got:

http://www.codeproject.com/KB/vista-...Elevation.aspx

cheers,
Dave
My System SpecsSystem Spec
Old 07-30-2008   #9 (permalink)
Mr. Arnold


 
 

Re: UAC: Elevate process only when needed, was: Vista UAC - get app to request escalation for a task


"d-42" <db.porsche@xxxxxx> wrote in message
news:eb732297-49d9-4f32-9aa6-eb11117d39ed@xxxxxx
On Jul 30, 3:30 am, Markus Mayer
<_nospam_usenet_nospam_@_nospam_defx_nospam_.de> wrote:
Quote:

> Markus Mayer schrieb:
>
Quote:
Quote:

> >>>> How do I ask for escalation from within a program?
> >>> Your program would use the Vista UAC manifest to provide the needed
> >>> credentials during program runtime, look it up use Google.
> >> But I don't want the entire program need escalation, just the one
> >> rarely used feature. I take it that's not possible? That I have to
> >> spin-off the feature into its own executable, and provide a separate
> >> manifest requiring escalation for that?
>
Quote:

> > What I need is that the program only asks for elevation when needed -
> > that is, if, and only if, it needs to write to "program files".
> > Any idea how to accomplish that?
> > (Didn't find any clue in the links provided)
>
> Hm. I obviously missed the part saying "This is the only time
> applications can do this as applications cannot change their level later
> and decide to elevate once running".
> Doesn't solve the problem, though. What's the magic of these "shield"
> buttons? Do they simply call an executable with a "run as administrator"
> constraint?
>
> Markus
In follow up I also found this article which is quite informative, and
really, more applicable than the other links we got:

http://www.codeproject.com/KB/vista-...Elevation.aspx


Why go through all that? It's free.

http://www.tweak-uac.com/what-is-tweak-uac/

My System SpecsSystem Spec
Old 07-31-2008   #10 (permalink)
d-42


 
 

Re: UAC: Elevate process only when needed, was: Vista UAC - get appto request escalation for a task

On Jul 30, 3:05*pm, "Mr. Arnold" <MR. Arn...@xxxxxx> wrote:
Quote:

> "d-42" <db.pors...@xxxxxx> wrote in message
Quote:

> Why go through all that? It's free.
>
> http://www.tweak-uac.com/what-is-tweak-uac/
So lets just tell our customers turn off all Vista's security and just
run as administrator? How can you possibly think that to be an
intelligent solution?

Not only will enterprises reject that option, and as a result, reject
our software outright (as they should), but we will perpetuate the
situation that has caused XP to become the malware cesspool it is.

Thanks, but no thanks. I want my software to run within Vista's least
privileged security model, escalate when absolutely needed, and be
accepted by customers and end users.

I look forward to the day when the suggestion to just 'run as
administrator and disable all the security to run our software' is as
laughable on Windows as it is on Linux, OSX, BSD, Solaris, AIX, and
any other respectable OS out there. Its sad that it hasn't reached
that point already.

-cheers,
Dave
My System SpecsSystem Spec
Reply

« APPCRASH | WDS 4.0 »
Thread Tools


Similar Threads
Thread Forum
Task Scheduler Compatibility module task status update failed General Discussion
Task Scheduler Error-task image corrupt or has been tampered with User_Feed_Synchroni General Discussion
Task Scheduler: Create task to open webpage? Vista General
Schedule a task with Vista task Scheduler wakes up computer and mo Vista General
Task scheduler returns an error : the task image is corrupt ortamp Vista performance & maintenance


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46