Well I have a trayIcon
program that requires administrator permission to run, I will like to create an option to start the program at system boot.
This is what I have tried:
try
{
RegistryKey key = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
Assembly curAssembly = Assembly.GetExecutingAssembly();
key.SetValue(curAssembly.GetName().Name, curAssembly.Location);
}
catch
{ }
and this one
RegistryKey reg = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
string path = Application.ExecutablePath.ToString();
reg.SetValue("AMD Service Closer", "\"" + path + "\"");
Both are working since they add the registry key:
But when I restart, shutdown or whatever my computer it doesn't start the program. What am I doing wrong?