I am using the following code to manage the automatic startup of my application. The application has been set up to require admin privileges, and indeed, does ask for them.
RegistryKey rkApp = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
if (checkRunOnStartup.Checked)
{
rkApp.SetValue("MyApp", Application.ExecutablePath.ToString());
}
else
{
rkApp.DeleteValue("MyApp", false);
}
This does not work on any system I have tested on, except from my development machine. What am I doing wrong here?