"Requested registry access is not allowed." on Windows 7 / Vista
I'm attempting to write a key to Registry. It works on Windows XP, but fails on Windows 7 / Vista.
The code below throws a Security Exception with description "Requested registry access is not allowed."
RegistryKey regKey =
Registry.LocalMachine.OpenSubKey("SOFTWARE\\App_Name\\" + subKey, true);
I realise that this has to do with the UAC settings, but I couldn'开发者_开发技巧t figure out an ideal workaround.
I don't want to fork out another process, and may be don't even want to request for any credentials. Just want it to work the same way as on Windows XP. I have modified the manifest file and removed requestedExecutionLevel node. This seems to do the trick.
Is there any other possible workaround, and are there any serious flaws with the "manifest" solution?
You do not have permissions to write to global key for the whole machine. Can you store your data under Current user key? That should not need administrator permissions.
I also had same problem with you and I changed LocalMachine to CurrentUser like this
RegistryKey regKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\\App_Name\\" + subKey, true);
精彩评论