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
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
You can't. The only other way to run elevated without the user's consent is as a scheduled task.
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.
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.
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?