Written program in WPF.

This program must be run when the operating system boots. I programmatically write to the desired registry key. After that, in the task manager, I see that the program is being installed in autorun, but it does not start the next time the system is booted. Previously (for example, in Windows 7) there were no problems. Perhaps not enough privileges.

How to programmatically autorun with admin rights? Maybe this is the problem?

I tried to put the program shortcut in the Startup folder. No reaction!

  • In the properties of the application (exe) set rights - tCode
  • And how exactly do you put the shortcut in the "Startup" directory? Show your code. - VladD
  • And why your program admin rights, if not a secret? - VladD
  • The program must be signed. Or through the service. - Qwertiy
  • What rights do you mean? I implemented the application manifest in the requireAdministrator access and even the highestAvailable access. No effect. - PWLSoft

1 answer 1

Here is the code to add your program to startup (Windows 10)

RegistryKey regKey = Registry.CurrentUser.CreateSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Run\\"); regKey.SetValue("MyApp", Assembly.GetExecutingAssembly().Location); regKey.Close(); 
  • Dear MaximK, this is exactly what I did in the code. - PWLSoft
  • Which branch are you trying to add a key to? CurrentUser or LocalMachine? - MaximK
  • I tried both there and there. In principle, adding a current user would be enough for work. - PWLSoft
  • The user under which the addition is NOT an administrator? - MaximK
  • Of course the administrator! - PWLSoft