User rights for Registry

  • Thread starter Thread starter RF
  • Start date Start date
R

RF

Hi,

I have an app that I need to set some values in the CurrentUser and
LocalMachine of the Registry. If the user has administrator previledges, no
problems occur. However, if the user if of type "limited" or
non-administrator, I receive an exception when trying to write in the
LocalMachine.

How can I bypass or impersonate the administrator to enable the app to write
values in the LocalMachine.

Thanks again,

RF
 
Why don't you set the permissions on the key instead. "Bypassing" certainly
won't work, and impersonating an administrator is probably a bad idea.
 
You have to request permission to write

System.Security.Permissions.RegistryPermission permission = new
System.Security.Permissions.RegistryPermission(

System.Security.Permissions.RegistryPermissionAccess.AllAccess,@"HKEY_LOCAL_
MACHINE\Software\MySoftware\MyKey");

permission.Demand();
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top