Click here to Skip to main content
15,308,835 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to run a program when computer restart?

You have a number of options to do this.

A) You could place a short cut of the program in the start folder. This will start the program automatically once the operating system loads.

B) You could use a windows service to launch the program.
SoMad 12-Jul-12 15:08pm
Option A) will run the program once the user logs in, not when the operating system loads. Since the OP did not specify the details, I will consider this a valid answer.

Soren Madsen
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.

Refer: Running a program at startup[^]

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