views:

50

answers:

4

I read how to do it with a service, but i wanna know if it's possible with a simple application. I'm using c#.

Thank you

+2  A: 

You can't. The only other way to run elevated without the user's consent is as a scheduled task.

Hans Passant
errm, so a service is the only way ? Then, could a service start my application ? My application has some graphical components, that's why i can't make it a service.
Red
ummm, have you tried scheduled tasks?
x86shadow
You don't want to have the service start your application because you'd have to mark it as interact with the desktop and the application would run elevated. This opens up huge possibilities that the program could then be exploited to run other programs elevated and basically compromise the whole machine.
Christopher Painter
A: 

It's not possible. The closest experience you could have would be to create a service to run elevated and a winforms app that runs without elevation and is just a front end to the service. You have to be careful though, you could cause security concerns if you don't wall if off correctly.

Christopher Painter
I guess i'll have to do that, thanks !
Red
+1  A: 

Windows will not run an elevated application on startup because it doesn't want to prompt you for a million startup applications. Technically you can get around this by writing a simple launcher that ShellExecute's your real application, but that will prompt you at startup and is quite annoying. The best approach as others have said is to move the tasks you require administrative privileges for into a service and keep the user interface stuff separate.

Luke
+1  A: 

I encourage you to read a post on the UAC team's blog regarding why startup applications are blocked from requiring elevation. One thing to consider: requiring elevation completely prevents standard users from using your app.

The official guidance: your startup program should not require elevation. To be honest, I'm having difficulty imagining a scenario where you could legitimately require elevation in a startup app. Could you provide more details about why you need elevation?

josh3736
My guess is that he's trying to delegate specific administrative functions to standard users or he's working around an upstream application design problem.
Christopher Painter