Home > Software engineering >  How to add application to windows startup sending arguments in a .net WPF application?
How to add application to windows startup sending arguments in a .net WPF application?

Time:01-18

I have a .net WPF desktop application that I developped using Visual Studio and I want to add this application to windows startup. Windows startup should run this application sending an argument "Start" so that program will know that it is started after logon instead of user. I have seen some solutions for adding this app to start up but could not find any example that starts app with arguments. Example code fragment:

Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
key.SetValue("Your Application Name", Application.ExecutablePath);

CodePudding user response:

Just set the value not to the Application.ExecutablePath only, but with the params itself appended. Example from my registry:

Key:
MicrosoftEdgeAutoLaunch_AC4772F08F551843066B27D28EB56714

Value:
"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" --no-startup-window --win-session-start /prefetch:5
  • Related