Click here to Skip to main content
11,410,365 members (42,314 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C# Windows
How do I run a program written with C# at startup?
Posted 31-Oct-10 1:07am
Edited 31-Oct-10 3:55am
Nish Nishant601.5K
Rate this: bad
Please Sign up or sign in to vote.

Solution 7

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,
Espen Harlinn at 31-Jan-11 15:18pm
Once more a good answer, and some nice links too, 5+ :)
SAKryukov at 31-Jan-11 16:05pm
Thank you,
This is again about learning what's on the system.
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.
Dalek Dave at 1-Nov-10 7:25am
Good Answer.
MDNadeemAkhter at 3-Nov-10 9:42am
5 From Me Good Answer
Chanchal Kumar Ghosh at 16-Nov-10 4:36am
+5 Very good answer...
binadi007 at 6-Apr-14 23:45pm
What is the purpose of RegistryValueKind.ExpandString?
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

use given Link to Run Program at Startup

Rate this: bad
Please Sign up or sign in to vote.

Solution 5

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".
Rate this: bad
Please Sign up or sign in to vote.

Solution 6

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

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 129
1 Sascha Lefévre 95
2 Maciej Los 68
3 BillWoodruff 60
4 OriginalGriff 60
0 Sergey Alexandrovich Kryukov 8,755
1 OriginalGriff 6,915
2 Maciej Los 3,390
3 Abhinav S 3,248
4 Peter Leow 3,059

Advertise | Privacy | Mobile
Web03 | 2.8.150414.5 | Last Updated 30 Jan 2011
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100