Answer the question
In order to leave comments, you need to log in
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();
}
Answer the question
In order to leave comments, you need to log in
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 questionAsk a Question
731 491 924 answers to any question