3

I'm trying to add a key to LocalMachine in registry. I'm 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 DO run it on Administrator account. I event run it with 'run as administrator", but nothing is added to registry :(. When I change the LocalMachine to CurrentUser, actually it is added to CurrentUser key. But how to force it to be added to LocalMachine?

2
  • 1
    Maybe this answer will help you. stackoverflow.com/questions/2723413/… Feb 19, 2013 at 11:42
  • Strange, I've just tested your code as it is, the key was added to the registry just fine, under HKEY_LOCAL_MACHINE/SOFTWARE, as expected. Windows 7 machine here. Feb 19, 2013 at 11:47

1 Answer 1

13

Got it. Actually it was added, but with my x64 system I couldn't see it in simple C:\Windows\regedit.exe. Go to C:\Windows\SysWOW64\regedit.exe to see it in x64

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.