Click here to Skip to main content
15,893,487 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

Please any one tell me , how automatically start my c# application(Project, i mean exe) when i start my computer. For that i have to write some c# code or have any windows setting...?


Thank you
Posted

 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 25-Apr-11 2:44am    
Very good, my 5 (as this reference shows my Solution as well :-)
Please see my answer on this page as well.
--SA
Tarun.K.S 25-Apr-11 3:10am    
:) Thanks!
Kim Togo 25-Apr-11 2:46am    
My 5. Good link :-)
Tarun.K.S 25-Apr-11 3:11am    
Thanks Kim! :)
prashanthv 25-Apr-11 2:48am    
Thank You.. :-)
There is a number of way.

One way is the simplest and perhaps the weakest: add a LNK file in the Start menu under "Startup". It can be per user or for all users and start up your application right after the user logs in.

Another, most powerful option is creation of a Windows Service. If you install or configure it as "automatic" it will be run under Service Manager on system start-up and will keep running when the users log in and out. You can capture different system events and act properly. This approach is the most difficult and will take logging and extra skills in debugging.

All other ways are related to programmatic adding nodes to the system registry. I have one "secret weapon" which helps me to learn where you can hook up different phases of start up. This is Sysinternals AutoRuns utility. Go to Sysinternals Web site and download Sysinternals Suite: http://technet.microsoft.com/en-us/sysinternals/bb842062[^]. You can download separate utilities (see http://technet.microsoft.com/en-us/sysinternals/bb545027[^]) but the whole Suite is must-have for a developer.

Unpack and run AutoRuns, traverse all the sections, read help. It will show you all the places where you can trigger start up of your application. All the nodes has "jump to" feature which will jump to a registry node using Regedit. This utility can be uses as the ultimate source of knowledge on the topic.

—SA
 
Share this answer
 
Comments
Kim Togo 25-Apr-11 2:47am    
My 5, SA. Good description :-)
Sergey Alexandrovich Kryukov 25-Apr-11 3:17am    
Thank you, Kim.
--SA
prashanthv 25-Apr-11 2:49am    
Thank You.. :-)
Sergey Alexandrovich Kryukov 25-Apr-11 3:17am    
You're welcome.
Thanks for accepting this answer.
Good luck, call again.
--SA
Tarun.K.S 25-Apr-11 3:12am    
Elegant answer! 5+
First add the object of the registrykey....

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


then below function is made under btn_click event and the check box check...

private void btn_ok_Click(object sender, EventArgs e)
       {
           if (chk_run.Checked)
           {
               rkApp.SetValue("AppName", Application.ExecutablePath.ToString());
           }
           else
           {
               rkApp.DeleteValue("AppName", false);
           }
       }
 
Share this answer
 
v2
Comments
Member 8816575 3-Jul-12 6:13am    
where to add this code?
Hi,

It's windows settings.

Goto:
Program->Startup

Just Put the shortcut of your application here.

Regards
Ankit
 
Share this answer
 
Comments
Kim Togo 25-Apr-11 2:45am    
My 5. Nice and simple
prashanthv 25-Apr-11 2:49am    
Thank You.. :-)
Hi there,

If you go 2 your start menu, you'll see a menu called "Startup" in "programs". Just create a shortcut to your EXE and put it in that menu folder. It'll start automatically next time you restart your PC.

Hope this helps :)
 
Share this answer
 
Comments
Kim Togo 25-Apr-11 2:45am    
My 5. Nice and simple
prashanthv 25-Apr-11 2:49am    
Thank You.. :-)

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