Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I set a program to launch at startup

Tags:

c#

windows

I have a small application with a CheckBox option that the user can set if they want the app to start with Windows.

My question is how do I actually set the app to run at startup.

ps: I'm using C# with .NET 2.0.

like image 966
Spidey Avatar asked Mar 23 '09 18:03

Spidey


People also ask

How do I choose which programs start automatically?

Click the Windows logo at the bottom left of your screen, or press the Windows key on your keyboard. Then search and select "Startup Apps." 2. Windows will sort the applications that open on startup by their impact on memory or CPU usage.


1 Answers

Thanks to everyone for responding so fast. Joel, I used your option 2 and added a registry key to the "Run" folder of the current user. Here's the code I used for anyone else who's interested.

    using Microsoft.Win32;     private void SetStartup()     {         RegistryKey rk = Registry.CurrentUser.OpenSubKey             ("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);          if (chkStartUp.Checked)             rk.SetValue(AppName, Application.ExecutablePath);         else             rk.DeleteValue(AppName,false);                  } 
like image 92
Spidey Avatar answered Oct 07 '22 06:10

Spidey