diff --git a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs index 57bf389fe..817018b49 100644 --- a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs +++ b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs @@ -472,11 +472,33 @@ namespace MediaBrowser.Common.Implementations } } + /// + /// Defines the full path to our shortcut in the start menu + /// + protected abstract string ProductShortcutPath { get; } + /// /// Configures the auto run at startup. /// private void ConfigureAutoRunAtStartup() { + if (ConfigurationManager.CommonConfiguration.RunAtStartup) + { + //Copy our shortut into the startup folder for this user + File.Copy(ProductShortcutPath, Environment.GetFolderPath(Environment.SpecialFolder.Startup), true); + } + else + { + //Remove our shortcut from the startup folder for this user + try + { + File.Delete(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Startup), Path.GetFileName(ProductShortcutPath))); + } + catch (FileNotFoundException) + { + //This is okay - trying to remove it anyway + } + } } /// diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.cs index d5a505792..f9b2840f4 100644 --- a/MediaBrowser.ServerApplication/ApplicationHost.cs +++ b/MediaBrowser.ServerApplication/ApplicationHost.cs @@ -128,6 +128,14 @@ namespace MediaBrowser.ServerApplication /// The HTTP server. private IHttpServer HttpServer { get; set; } + /// + /// The full path to our startmenu shortcut + /// + protected override string ProductShortcutPath + { + get { return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu), "Media Browser Server.lnk"); } + } + /// /// Runs the startup tasks. ///