Click here to Skip to main content
15,797,672 members
Please Sign up or sign in to vote.
4.50/5 (8 votes)
See more:
How do I run a program written with C# at startup?
Updated 31-Oct-10 3:55am

Most fundamental option is writing a Windows Service is a serious option. It gives important benefits over regular applications, but also more difficult to develop and debug. The service keeps running when users log out and log in.

For all other ways, I have a more comprehensive method which I find very robust. You can find all different ways to register application for loading once or on regular basis following SysInternals application called AutoRuns:

1) Go to SysInternals site:[^].
2) Download SysInternals Suit:[^]; you can also download separate applications, but there are more useful things, read utilities Index:[^].
3) Unpack and run AutoRuns, read it help and look at the top-level items of the tree: they show when you can install your applications.
4) Activate context menu and select "Jump To"; it will open Regedit on a selected item.
5) Write installation application which writes the path to your application and parameters in a right place in the Registry.

Good luck,
Share this answer
Espen Harlinn 31-Jan-11 15:18pm    
Once more a good answer, and some nice links too, 5+ :)
Sergey Alexandrovich Kryukov 31-Jan-11 16:05pm    
Thank you,
This is again about learning what's on the system.
You need to use the Registry for running a program at startup. You can use the RegistryKey class that's in the System.Win32 namespace. The following code shows how to do this:

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.
Share this answer
Dalek Dave 1-Nov-10 7:25am    
Good Answer.
MDNadeemAkhter 3-Nov-10 9:42am    
5 From Me Good Answer
Chanchal Kumar Ghosh 16-Nov-10 4:36am    
+5 Very good answer...
binadi007 6-Apr-14 23:45pm    
What is the purpose of RegistryValueKind.ExpandString?
use given Link to Run Program at Startup

Share this answer
you need to use the registery to run program at sturt up.
you must create a key in "Hkey_current_user\Software\Microsoft\Windows\CurrentVersion\Run".
Share this answer
A program can be loaded at startup from various places. One of Which is by placing shortcut to any application in then Windows STARTUP Folder.

This is usually located at C:\Windows\Start Menu\Programs\Startup in Windows 95, 98, or ME,
or at C:\Documents and Settings\All Users\Start Menu\Programs\Startup in Windows XP for all user
or C:\Documents and Settings\{USER NAME}\Start Menu\Programs\Startup for specific User.
However, it may be at a different location on your computer if you have tweaked with the configuration.
You can view the Startup folder in Windows Explorer by clicking the appropriate link (immediately above) if you have used the default; or you can view it by clicking Start | All Programs | StartUp.

You can place any shortcut or even application in the mentioned folder to run any application at startup.

I hope this might work
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900