M
M
Michael2015-06-02 20:44:31
Access rights
Michael, 2015-06-02 20:44:31

C#. How to give permission to add/remove registry keys?

In my application, I implement the ability to add / remove the context menu in the explorer. I'm trying to add/remove a key here:

HKEY_CLASSES_ROOT\jpegfile\shell
jpegfile - file type (I use several of them)

But this only works if you run the application with administrator rights.
Questions:
How to allow the application access to these registry branches?
Do I need to apply administrator rights to the application to do this? (and if so, how to get rid of the security window every time the application starts)
Maybe you can do the integration into the explorer context menu differently? (to not require admin rights)
---
Solution:
Thanks to dordzhiev for the tip. Creating a context menu for a specific user does not require administrator rights. I create it here: HKEY_CURRENT_USER\Software\Classes\jpegfile\shell\

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
dordzhiev, 2015-06-02
@gmikhail94

Depending on where to write. HKCR is a virtual hive consisting of HKCU\Software\Classes and HKLM\Software\Classes. If you write in HKCU, then all the rules, rights are not needed. But the association will only be for the current user.

S
Sergey Mozhaykin, 2015-06-03
@smozhaykin

Perhaps you can write a service that will start with administrator rights when the application is installed. Then the application through this service will change the registry values. It seems that this is done to automatically update some applications, so as not to constantly ask the user for permission to install.

G
GavriKos, 2015-06-02
@GavriKos

How to allow the application access to these registry branches?

This is not decided by the programmer, but by the security policies of a particular computer.
Optional - again see security policies. There is no way you can get rid of the security window from the application side. Only from a specific computer.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question