0

I add a shortcut of my .exe file to the startup registry using this code:

  RegistryKey rk = Registry.CurrentUser.OpenSubKey
                            ("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
            rk.SetValue("SlashA006", Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\SlashA006\SlashA006 - Shortcut.lnk");

When I reload the computer, the program loads but I get an error (a messagebox saying only: error) and my program won't work. I have no clue what could be causing this. Any ideas? Thank you

wilky
  • 33
  • 7
  • Why do you add a shortcut instead of a direct call to your Exe? Also, be sure that your program works even if it is launched from a folder different from the folder where your program is stored – Steve Mar 15 '18 at 22:45
  • @Steve so when I added the exe itself to startup, I got error messages too. So the .exe is in Program Files x86, and it relies on folders in x86, so when I run it out of the folder bad stuff happens. Does that make sense or no? sorry if I'm not clear – wilky Mar 15 '18 at 22:47
  • Check this answer: https://stackoverflow.com/questions/2822951/use-registry-to-startup-a-program-and-also-change-the-current-working-directory – Steve Mar 15 '18 at 22:56
  • @Steve I will, but I feel the shortcut method would be helpful if it can work. Do you have any ideas? if not thats fine – wilky Mar 15 '18 at 22:59

0 Answers0