How to register a global hotkey for your application in C#

How to register a global hotkey for your application in C#

Register a hotkey for your application that can be triggered even if your form is minimized and does not have focus. More »

How to download a file in C# (progressbar and download speed)

How to download a file in C# (progressbar and download speed)

Learn how to download files in C# while displaying the percentage and the download speed. More »

UDP hole punching implementation in C#

UDP hole punching implementation in C#

Learn how to implement UDP hole punching so you can make your clients life a lot easier by not forcing them to open ports on their end. More »

 

Start application at Windows startup with C#

The following snippet will allow you to add your application in the registry so it will launch when Windows start. Alternative you can use Environment.SpecialFolder.Startup to place a shortcut of your application in the startup folder which will have the same effect.

Note that this snippet will add an entry in HKEY_CURRENT_USER which means the program will only launch at startup for the user that is currently logged in when you run the code. If you want your program to run at startup for all users you will need to use HKEY_LOCAL_MACHINE instead but keep in mind that you will require administration rights in order to do that.

Register program to start with Windows:

Stop program from starting with Windows:

Share on FacebookTweet about this on TwitterShare on Google+Share on StumbleUponShare on LinkedInShare on RedditPin on PinterestShare on TumblrDigg thisPrint this pageEmail this to someone

6 Responses to Start application at Windows startup with C#

  1. Paul Aicher says:

    here it is as a C# property.

  2. Capparelli says:

    How can I make it run with adminitrative privileges?

  3. Ajmal says:

    How to Identify this autorun or manually triggered?

  4. nouman says:

    the register will be one time or every time on load , suppose i call add function 1 time on load then app start then i remove the call to fucntion from loadform

    • CooLMinE says:

      There is no need to remove it, except if you want to.

      Usually applications allow the users to decide if they want the program to start on Windows startup or not.

      This means you will need to read from the registry if your program is already set to start or not, then simply allow the user toggle on/off while you execute the appropriate method in the background.

  5. Jersey says:

    Nice job, it’s a great post. The info is good to know!

Leave a Reply

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