# HG changeset patch # User sl # Date 1421587108 -3600 # Node ID f0015e909f41183cdbe3ffc5059638ed8b32dadb # Parent 787dee27fc0a9c18a47b52df6d4eb5ad722b7161 Auto start now properlly working with ClickOnce. diff -r 787dee27fc0a -r f0015e909f41 Server/SharpDisplayManager.csproj --- a/Server/SharpDisplayManager.csproj Sun Jan 18 12:35:22 2015 +0100 +++ b/Server/SharpDisplayManager.csproj Sun Jan 18 14:18:28 2015 +0100 @@ -27,10 +27,11 @@ http://publish.slions.net/SharpDisplayManager/ Sharp Display Manager Slions + Sharp Display Manager true index.htm false - 15 + 20 0.1.0.%2a false true diff -r 787dee27fc0a -r f0015e909f41 Server/StartupManager.cs --- a/Server/StartupManager.cs Sun Jan 18 12:35:22 2015 +0100 +++ b/Server/StartupManager.cs Sun Jan 18 14:18:28 2015 +0100 @@ -16,6 +16,7 @@ using System.Security; using System.Security.Principal; using System.Windows.Forms; +using System.Deployment.Application; namespace SharpDisplayManager { @@ -115,7 +116,7 @@ { string value = (string)key.GetValue("SharpDisplayManager"); if (value != null) - startup = value == Application.ExecutablePath; + startup = value == LaunchCommand; } } isAvailable = true; @@ -182,10 +183,23 @@ catch (IOException) { } } + string LaunchCommand + { + get + { + //Executable path won't launch ClickOnce Application with deployment enabled. + //return Application.ExecutablePath; + //Instead we need to launch the application using the .appref-ms shortcut. + //That shortcut is located at \\\.appref-ms + return string.Concat(Environment.GetFolderPath(Environment.SpecialFolder.Programs), "\\", "Slions", "\\", "Sharp Display Manager" , "\\" ,"Sharp Display Manager", ".appref-ms"); + } + } + private void CreateRegistryRun() { RegistryKey key = Registry.CurrentUser.CreateSubKey(REGISTRY_RUN); - key.SetValue("SharpDisplayManager", Application.ExecutablePath); + //Rather than the executable name we pass in the ClickOnce shortcut to make sure we launch with deployment support + key.SetValue("SharpDisplayManager", LaunchCommand); } private void DeleteRegistryRun()