C # add key to registry in LocalMachine fails
I am trying to add a key to LocalMachine
the registry. I am using this code:
System.Diagnostics.Debugger.Launch();
RegistryKey key = Registry.LocalMachine.OpenSubKey("SOFTWARE", true);
RegistryKey newkey = key.CreateSubKey("1asdasds", RegistryKeyPermissionCheck.ReadWriteSubTree);
newkey.SetValue("ads", "ddsds");
newkey.Close();
I ran it in an administrator account. Event I fire it with "run as administrator", but nothing is added to the registry :(. When I change LocalMachine
to CurrentUser
, it is actually added to the key CurrentUser
. But how to get it to add to LocalMachine?
+3
source to share