I made an application that launches during startup, with the next code below.
The process runs on the process manager tool after the restart, but I can't see
the application on the screen.
When I open the same .exe file from the startup registry value the program runs perfect.
// The path to the key where Windows looks for startup applications
RegistryKey rkApp = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
// Add the value in the registry so that the application runs at startup
rkApp.SetValue("MyApp", Application.ExecutablePath.ToString());
What can I do to fix it up?
You could try copying a shortcut to your application into the startup folder instead of adding things to the registry. You can get the path with
Environment.SpecialFolder.Startup
. This is available in all .net frameworks since 1.1.Alternatively, maybe this site will be helpful to you, it lists a lot of the different ways you can get an application to auto-start.
If you could not set your application autostart you can try to paste this code to manifest
or delete manifest I had found it in my application
for WPF: (where lblInfo is a label, chkRun is a checkBox)
this.Topmost is just to keep my app on the top of other windows, you will also need to add a using statement " using Microsoft.Win32; ", StartupWithWindows is my application's name
I think there is a specific Win32 API call which takes the application path and puts it in the registry automatically for you in the proper location, I've used it in the past but I don't remember the function name anymore.
Code is here(win form app):
OK here are my 2 cents: try passing path with each backslash as double backslash. I have found sometimes calling WIN API requires that.