dimanche 12 avril 2015

Add application to Windows startup in C#?

I want to add my application to Windows startup programatically. I am using the below code. But when I shut down and start Windows again then my application doesn't start.



public static void AddApplicationToStartup()
{
using (RegistryKey key = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true))
{
key.SetValue("My Program", "\"" + Application.ExecutablePath + "\"");
}
}

Aucun commentaire:

Enregistrer un commentaire