"Requested registry access is not allowed." on Windows 7 / Vista
Posted
by Trainee4Life
on Stack Overflow
See other posts from Stack Overflow
or by Trainee4Life
Published on 2010-03-29T09:24:09Z
Indexed on
2010/03/29
9:33 UTC
Read the original article
Hit count: 692
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?
© Stack Overflow or respective owner