A
A
Almost2017-08-28 18:49:06
WPF
Almost, 2017-08-28 18:49:06

Why does program autoload not work C# WPF?

The program does not start after adding data to the register. The line is added to the register, but after turning on the system does not start. The absence of quotes does not affect the operation in any way. The application has administrator rights enabled. In addition, the application is displayed in the task manager in the "Startup" tab. Tried a lot, nothing helps. It does not work in Win 10 or Win 7. If placed in the HKEY_CURRENT_USER directory, it does not work either. Why?

public void SetAutoload(bool set) {
   Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run\\", true);
   if (set) {
      key.SetValue("Appname", "\"" + AppDomain.CurrentDomain.BaseDirectory + "Appname.exe" + "\"");
   } else {
      key.DeleteValue("Appname", false);
   }
   key.Close();
}

ac0f6219a158446ba6836c6014385b65.png
UPD.: even if you add a program shortcut to the startup folder, the program does not start. Apparently it has something to do with administrator rights.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stanislav Makarov, 2017-08-28
@Almost

In modern Windows, applications that require privilege escalation can only be started normally using the Task Scheduler . Privilege escalation (which in turn will trigger UAC if enabled) is not possible for startup programs (whether in a folder or through the registry).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question