it should be this simple. this code looks good. it doesnt crash. so why doesnt it do what it says to do? I cant change anything in the registry like this but all google searches say this is how it should be. any help is greatly appreciated.
private void button2_Click(object sender, EventArgs e)
{
RegistryKey myKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\",true);
myKey.SetValue("AutoAdminLogon", "1");
}
You may be dealing with Win7’s “shadow registry” issue wherein some registry changes are not made to the “actual” registry, but a “shadow” copy that protects the original in the event of malevolent access. Registry changes are redirected to a user-specific region of the registry, but are rendered to appear as though they are in HKLM (as in your example).
Registry virtualization was introduced in Vista, I believe, but is at least a good candidate to explain your problem.
http://msdn.microsoft.com/en-us/library/bb530198.aspx
Failing this, you may be making changes against the Wow64 node of the registry. Check for your changes under HKLM\Software\Wow6432Node\Microsoft\Windows NT\CurrentVersion\Winlogon and see if your changes are being made there instead. On 64-bit versions of Windows, 32 bit code runs under the WOW subsystem, and registry calls from such apps are routed to the Wow6432 node in the registry – all unbeknownst to the calling 32-bit app.