how can I run an app automatic after restart? (by c# code) I create A new string in 'runOnce' key in registry with the path of the App. the OS run this APP before it load the OS my problem is: My APP loads but explorer doesn't load, after I close my APP, explorer loads I restart the computer in APP, and after restart I want that my APP reopen
In Sign-in options, scroll down the page until you see the “Restart apps” option. Flip the switch just below it until it's set to “On.” After that, close Settings. The next time you reboot or log out and log back in, what Microsoft calls your “restartable apps” will be reloaded automatically.
When you click restart from your app, make the following modifications to the registry:
Create an entry in HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
registry branch.
Use
Registry.LocalMachine.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run\\YourAppName");
to create an entry.
And
RegistryKey myKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run\\YourAppName", true);
myKey.SetValue("YourAppName", "AppExecutablePath", RegistryValueKind.String);
to set the run path.
After the system has restarted, your app starts and removes the restart entry by calling this:
Registry.LocalMachine.DeleteSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run\\YourAppName");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With