Look here:
Running a program at startup[
^]
You need to use the Registry for running a program at startup:
RegistryKey rk = Registry.CurrentUser;
RegistryKey StartupPath;
StartupPath = rk.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true);
if (StartupPath.GetValue("ProjectName") == null)
{
StartupPath.SetValue("ProjectName", Application.ExecutablePath, RegistryValueKind.ExpandString);
}
Note:
RegistryKey
is in the
System.Win32
namespace, hence don't forget to import it.