Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Need to elevate permissions without UAC pop ups

Tags:

c#

uac

I have an application which is a launcher for another application (my main one). The launcher goes to an FTP server, downloads updates and installs them. However, the update executable needs to copy some DLLs and EXEs to the installation directory of the main application, which is in Program Files. Because of that, I currently need to elevate the rights of the updater.

This is a problem because my application starts on boot, and in general will simply load to the system tray (the application is comparable to messenger/skype). If I start popping UAC warnings on the screen while trying to "silently" update the application, it's not so silent any more.

The only way I see right now to avoid the problem is to give all users permissions to the program files installation directory, but I am reluctant to do that. Any other ideas?

I'm using Windows 7, and the applications are in C#.

like image 869
Eldad Mor Avatar asked Nov 23 '10 18:11

Eldad Mor


1 Answers

Doing so would violate the basic principle of User Access Control.

There is no way to elevate permissions while avoiding the prompts, by design. If there was a way to do this, UAC would become useless.


That being said, you could try to design around the issue. Instead of making your program a startup/system tray application, you may want to consider making a windows service that does the update. This could run as an administrator on boot (instead of login), and it would already run with elevated permissions.

If you need a system tray application, it could be a separate app that "talks" to the service.

like image 96
Reed Copsey Avatar answered Nov 14 '22 23:11

Reed Copsey