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
?