开发者

"Requested registry access is not allowed." on Windows 7 / Vista

开发者 https://www.devze.com 2022-12-25 03:19 出处:网络
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 all

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);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号