I want that my application (a WPF Window) is launched on Windows startup. I tried different solutions, but no one seems to work. What i have to write in my code to do this?
I want that my application (a WPF Window ) is launched on Windows startup.
Share
You are correct when you say that you must add a key to the registry.
Add a key to:
if you want to start the application for the current user.
Or:
If you want to start it for all users.
For example, starting the application for the current user:
Just replace the line second line with
if you want to automatically start the application for all users on Windows startup.
Just remove the registry value if you no longer want to start the application automatically.
As such:
This sample code was tested for a WinForms app. If you need to determine the path to the executable for a WPF app, then give the following a try.
Just replace “Application.ExecutablePath.ToString()” with the path to your executable.