I used this code but it did not work
var path = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Run";
RegistryKey key = Registry.LocalMachine.OpenSubKey(path,true);
key.SetValue("test","test");
Nothing was added to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run