0

I created a C# application that listens and responds to a custom uri scheme. It was fairly easy to implement, however I had to manually edit the registry to register my application. If I would share my application with others, how can I make sure everything is set up correctly in their registries?

Programmatically creating the required registry keys at the startup of my application is problematic, because write access to HKEY_CLASSES_ROOT requires admin privileges. I'd rather not have my application always require to be ran as admin, so I was thinking of creating a second executable just for the registry stuff. Another idea I had is to include a .reg file that the user has to run manually. However these solutions seems like an unusual way to solve my problem.


I have tried adding the following to my app.manifest:

<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />

My application now gains access to the registry keys I need, but it makes UAC prompt the user for admin rights every time. This solution doesn't feel right... I was hoping to keep my application simple and easy to use. I've rarely seen any production application prompt for admin privileges.


I wonder, how do "real life" applications solve this problem? Or is it just a no-go for developers to write keys outside of HKEY_LOCAL_USER?

Community
  • 1
  • 1
Rudey
  • 4,717
  • 4
  • 42
  • 84
  • 1
    This is why most programs use installers, and why installers ask for admin privileges when they start. – Erik Mar 28 '15 at 00:54
  • 1
    You create them with your installer, which requires admin privileges to run. Since the installer is being run as an adminstrator, it has access to create those registry entries. A normal application should never require admin rights to run, but an installer will (and WIndows even does so automatically if your installer's name contains "install" or "setup"). – Ken White Mar 28 '15 at 00:54
  • See http://stackoverflow.com/q/17533/103167 – Ben Voigt Mar 28 '15 at 00:58

0 Answers0