From cc9f249afe4dd2b0ec96f59a748c67e301baca59 Mon Sep 17 00:00:00 2001 From: Eric Reed Date: Tue, 12 Mar 2013 15:28:06 -0400 Subject: Implement configureautorun in server #19 need to update nuget to put in mbt --- .../BaseApplicationHost.cs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'MediaBrowser.Common.Implementations/BaseApplicationHost.cs') 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 + } + } } /// -- cgit v1.2.3