C# Set Registry Value throws UnauthorizedAccessException
Follow the following code, note the additional true
argument:
RegistryKey key = Registry.LocalMachine.OpenSubKey("SYSTEM\\CurrentControlSet\\services\\Tomcat7",true);
key.SetValue("Start", 2, RegistryValueKind.DWord);
This might help ,
Link to similar issue on stack overflow
looks like you are opening the key read only … Google is your friend.