I have an application that is deployed with ClickOnce, and has an option to automatically start with Windows. However, when I restart Windows, my application starts successfully, but is not able to find the settings (I'm just using the built-in Settings functionality). However, if I close the auto-started app and restart it with the icon on the desktop, it is able to find it's settings.
To start automatically with Windows, I'm using the following code:
Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
if (runOnStartup == true)
key.SetValue("AppName", Application.ExecutablePath.ToString());
else
key.DeleteValue("AppName");
I noticed that the desktop shortcut doesn't point directly to an exe, but rather a url like:
http://pathToApp.application#AppName.application, Culture=neutral, PublicKeyToken=c8c0a22ba65cb9f4, processorArchitecture=x86
How can I get my auto-start app to work the same way as the shortcut does?