From cc574074b9375390e3a7252ea97abe89f387861f Mon Sep 17 00:00:00 2001 From: Eric Reed Date: Thu, 28 Feb 2013 12:04:25 -0500 Subject: [PATCH] Only try to shutdown server if actually running --- MediaBrowser.Installer/MainWindow.xaml.cs | 4 ++-- .../MainWindow.xaml.cs | 21 +++++++++++-------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/MediaBrowser.Installer/MainWindow.xaml.cs b/MediaBrowser.Installer/MainWindow.xaml.cs index 4268e5757..f3f3c7740 100644 --- a/MediaBrowser.Installer/MainWindow.xaml.cs +++ b/MediaBrowser.Installer/MainWindow.xaml.cs @@ -114,8 +114,8 @@ namespace MediaBrowser.Installer var version = await GetPackageVersion(); lblStatus.Content = string.Format("Downloading {0} (version {1})...", FriendlyName, version.versionStr); - // Now try and shut down the server if that is what we are installing - if (PackageName == "MBServer") + // Now try and shut down the server if that is what we are installing and it is running + if (PackageName == "MBServer" && Process.GetProcessesByName("mediabrowser.serverapplication").Length != 0) { using (var client = new WebClient()) { diff --git a/MediaBrowser.Uninstaller.Execute/MainWindow.xaml.cs b/MediaBrowser.Uninstaller.Execute/MainWindow.xaml.cs index 702c76bf6..9906af273 100644 --- a/MediaBrowser.Uninstaller.Execute/MainWindow.xaml.cs +++ b/MediaBrowser.Uninstaller.Execute/MainWindow.xaml.cs @@ -79,18 +79,21 @@ namespace MediaBrowser.Uninstaller.Execute if (Product == "Server") { RemoveShortcut(Path.Combine(startMenu, "MB Dashboard.lnk")); - using (var client = new WebClient()) + if (Process.GetProcessesByName("mediabrowser.serverapplication").Length != 0) { - lblHeading.Content = "Shutting Down Server..."; - try + using (var client = new WebClient()) { - client.UploadString("http://localhost:8096/mediabrowser/system/shutdown", ""); - } - catch (WebException ex) - { - if (ex.Status != WebExceptionStatus.ConnectFailure && !ex.Message.StartsWith("Unable to connect", StringComparison.OrdinalIgnoreCase)) + lblHeading.Content = "Shutting Down Server..."; + try { - MessageBox.Show("Error shutting down server. Please be sure it is not running before hitting OK.\n\n" + ex.Status + "\n\n" + ex.Message); + client.UploadString("http://localhost:8096/mediabrowser/system/shutdown", ""); + } + catch (WebException ex) + { + if (ex.Status != WebExceptionStatus.ConnectFailure && !ex.Message.StartsWith("Unable to connect", StringComparison.OrdinalIgnoreCase)) + { + MessageBox.Show("Error shutting down server. Please be sure it is not running before hitting OK.\n\n" + ex.Status + "\n\n" + ex.Message); + } } } }