I currently have problem in making my app autorun during startup in windows 8. I have tried to put the app in the registry. In fact I have tried both Local Machine and Current User approach:
RegistryKey rkHKLM = Registry.LocalMachine;
RegistryKey rkRun;
RegistryKey rkHKCU = Registry.CurrentUser;
RegistryKey rkRun1;
rkRun = rkHKLM.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Run", true);
rkRun1 = rkHKCU.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Run", true);
if (checkBox1.Checked)
{
rkRun.SetValue("MyApp", Application.ExecutablePath);
rkRun1.SetValue("MyApp", Application.ExecutablePath);
}
else
{
rkRun.DeleteValue("MyApp");
rkRun1.DeleteValue("MyApp");
}
This method does not work in Windows 8. But I don't have this problem in windows 7 or XP. Anything different for Windows 8? Is it there is any new approach?
- For your info, I have set the app to run as admin but still doesn't autorun on startup.
Add a link or batch file file to:
c:\Users\ (username) \AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
you could probably replace
c:\Users\ (username) \AppData\Roamingwith"%AppData%"in your code by