Run the application at Windows startup

Windows Startup Settings - Enabling Application Launch with Startup Folder and Checkbox Highlight
Learn how to make your application run at startup using a well placed registry key. Also you'll see how to stop the application from running at startup, and checking its current state.

The Visual Studio 2005 project below includes a tiny sample application with a checkbox which you can use to definy wether or not the application should run at startup. The project can very easily be converted to older versions of Visual Studio.

the application run or not run at startup involves a few simple lines of code for operating on the Windows Registry. More exactly the registry key we’re interested in is Run. The full path to it is HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run or if you want the setting for all the users of the operating system use HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run.

Before we start, make sure you add the following using directive:

using Microsoft.Win32;

Define a RegistryKey object we’re going to use for accessing the path to the Run registry key:

// The path to the key where Windows looks for startup applications

RegistryKey rkApp = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);

You can change CurrentUser to LocalMachine if you want the application to run at startup for all the users of the operating system.

Now here’s the code used to make the current application run at startup:

// Add the value in the registry so that the application runs at startup

rkApp.SetValue("MyApp", Application.ExecutablePath.ToString());

Of course, change MyApp to the name of your application as you want it to appear in the System Configuration Utility (msconfig.exe which can be opened by typing msconfig at Start Menu -> Run). Application.ExecutablePath.ToString()retrieves the path to the application executable that’s currently running, so we don’t have to write it ourselves, not to mention that we don’t normally know where the user installs the application.

So basically what we did here is add a value to the Run registry key, containing the name of the application and the path to the executable. That’s enough for the executable to run at startup.

Now how do we disable the application from running at startup. Obviously, we delete the registry value we just created:

// Remove the value from the registry so that the application doesn't start

rkApp.DeleteValue("MyApp", false);

And how do we check the current state of the application to see if it’s set to run at startup or not.

// Check to see the current state (running at startup or not)

if (rkApp.GetValue("MyApp") == null)


   // The value doesn't exist, the application is not set to run at startup

   chkRun.Checked = false;




   // The value exists, the application is set to run at startup

   chkRun.Checked = true;


Where chkRun is a Checkbox which gets checked if the application is set to run at startup, and unchecked if it isn’t.

There are a few other ways of making your application run at startup, such as adding it to the Startup folder of the Start menu, or adding a line to Win.ini, however using the Run registry key is the most reliable and popular method.

Nathan Pakovskie is an esteemed senior developer and educator in the tech community, best known for his contributions to With a passion for coding and a knack for simplifying complex tech concepts, Nathan has authored several popular tutorials on C# programming, ranging from basic operations to advanced coding techniques. His articles, often characterized by clarity and precision, serve as invaluable resources for both novice and experienced programmers. Beyond his technical expertise, Nathan is an advocate for continuous learning and enjoys exploring emerging technologies in AI and software development. When he’s not coding or writing, Nathan engages in mentoring upcoming developers, emphasizing the importance of both technical skills and creative problem-solving in the ever-evolving world of technology. Specialties: C# Programming, Technical Writing, Software Development, AI Technologies, Educational Outreach

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top