I need to write and read keys in Registry without administrator mode.First I want to know is this possible to do?
Please find below code (It's working fine, when Visual studio open in Administrator mode)
Write
RegistryKey key = Registry.LocalMachine.OpenSubKey("Software", true);
key.CreateSubKey("AppName");
key = key.OpenSubKey("AppName", true);
key.CreateSubKey("AppVersion");
key = key.OpenSubKey("AppVersion", true);
key.SetValue("myval", "677");
key.Close();
Read
RegistryKey key = Registry.LocalMachine.OpenSubKey("Software", true);
key.CreateSubKey("AppName");
key = key.OpenSubKey("AppName", true);
//if it does exist, retrieve the stored values
if (key != null)
{
string s = (string)key.GetValue("myval");
Console.Read();
key.Close();
}
Please any one suggest a way to do this. (I tried to add below line as well)
Error :
ClickOnce does not support the request execution level 'requireAdministrator'.