Is this the appropriate way to automatically start a .NET application on startup?

I am teaching someone the best practice by reorganizing a large project they were working on. One of the current features of the app is the ability to launch the app on Windows startup. The application currently does this using the Run section:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run

      

I haven't had a need to implement this feature before, so I'm not sure if this is the best way to make the application run on startup. Is access to this registry key what most users will have?

Would it be better to place the shortcut for the app in the folder specified instead Environment.GetFolderPath(SpecialFolder.Startup)

? It looks like creating shortcuts from .NET is pretty hacky, so I'm not sure if it's better.

edit:

It is clear from the current answers that I forgot something important. The Start on Windows behavior is optional and is part of the Program Options dialog box. It is valid (albeit silly) for the user to toggle multiple times while using the app.

+2


source to share


2 answers


It all depends on the intent of the application. If the application is intended for advanced users, it includes an easy way in the program to change this registry key, or is intended as a corporate solution that should not be removed, the choice of the registry key is good. If this is for general users and does not have an easy way to change this setting, go to the Startup folder.



In your particular case, using a registry key is great, thanks to the ability to easily change things.

+5


source


If your deployment is via MSI, then there is a way to do it from the deployment project configuration via visual studio.



This, of course, will end up putting a shortcut for your application in the user's startup folder, which you could do the same programmatically if you weren't deploying using MSI.

0


source







All Articles