From 75935224a809aea26215cd6c7a6ecf68434b9237 Mon Sep 17 00:00:00 2001 From: Jared Goodwin Date: Sat, 22 Feb 2020 18:22:27 -0800 Subject: [PATCH] Rename static helpers. --- Agent.Installer.Win/Agent.Installer.Win.csproj | 4 ++-- .../Services/CommandLineParser.cs | 2 +- Agent.Installer.Win/Services/InstallerService.cs | 16 ++++++++-------- .../{MessageBoxWrapper.cs => MessageBoxEx.cs} | 2 +- .../Services/{ProcessWrapper.cs => ProcessEx.cs} | 2 +- .../ViewModels/MainWindowViewModel.cs | 8 ++++---- 6 files changed, 17 insertions(+), 17 deletions(-) rename Agent.Installer.Win/Services/{MessageBoxWrapper.cs => MessageBoxEx.cs} (94%) rename Agent.Installer.Win/Services/{ProcessWrapper.cs => ProcessEx.cs} (93%) diff --git a/Agent.Installer.Win/Agent.Installer.Win.csproj b/Agent.Installer.Win/Agent.Installer.Win.csproj index a3df7ba2..21ef6939 100644 --- a/Agent.Installer.Win/Agent.Installer.Win.csproj +++ b/Agent.Installer.Win/Agent.Installer.Win.csproj @@ -81,11 +81,11 @@ Models\InstallerSettings.cs - + - + diff --git a/Agent.Installer.Win/Services/CommandLineParser.cs b/Agent.Installer.Win/Services/CommandLineParser.cs index 454776f6..92a4fbb1 100644 --- a/Agent.Installer.Win/Services/CommandLineParser.cs +++ b/Agent.Installer.Win/Services/CommandLineParser.cs @@ -28,7 +28,7 @@ namespace Remotely.Agent.Installer.Win.Services if (!key.Contains("-")) { Logger.Write("Command line arguments are invalid."); - MessageBoxWrapper.Show("Command line arguments are invalid.", "Invalid Arguments", MessageBoxButton.OK, MessageBoxImage.Error); + MessageBoxEx.Show("Command line arguments are invalid.", "Invalid Arguments", MessageBoxButton.OK, MessageBoxImage.Error); i -= 1; continue; } diff --git a/Agent.Installer.Win/Services/InstallerService.cs b/Agent.Installer.Win/Services/InstallerService.cs index 568037e7..75482982 100644 --- a/Agent.Installer.Win/Services/InstallerService.cs +++ b/Agent.Installer.Win/Services/InstallerService.cs @@ -87,15 +87,15 @@ namespace Remotely.Agent.Installer.Win.Services StopService(); - ProcessWrapper.StartHidden("cmd.exe", "/c sc delete Remotely_Service").WaitForExit(); + ProcessEx.StartHidden("cmd.exe", "/c sc delete Remotely_Service").WaitForExit(); await StopProcesses(); ProgressMessageChanged?.Invoke(this, "Deleting files."); ClearInstallDirectory(); - ProcessWrapper.StartHidden("cmd.exe", $"/c timeout 5 & rd /s /q \"{InstallPath}\""); + ProcessEx.StartHidden("cmd.exe", $"/c timeout 5 & rd /s /q \"{InstallPath}\""); - ProcessWrapper.StartHidden("netsh", "advfirewall firewall delete rule name=\"Remotely ScreenCast\"").WaitForExit(); + ProcessEx.StartHidden("netsh", "advfirewall firewall delete rule name=\"Remotely ScreenCast\"").WaitForExit(); GetRegistryBaseKey().DeleteSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Remotely", false); @@ -112,8 +112,8 @@ namespace Remotely.Agent.Installer.Win.Services private void AddFirewallRule() { var screenCastPath = Path.Combine(InstallPath, "ScreenCast", "Remotely_ScreenCast.exe"); - ProcessWrapper.StartHidden("netsh", "advfirewall firewall delete rule name=\"Remotely ScreenCast\"").WaitForExit(); - ProcessWrapper.StartHidden("netsh", $"advfirewall firewall add rule name=\"Remotely ScreenCast\" program=\"{screenCastPath}\" protocol=any dir=in enable=yes action=allow profile=Private,Domain description=\"The agent that allows screen sharing and remote control for Remotely.\"").WaitForExit(); + ProcessEx.StartHidden("netsh", "advfirewall firewall delete rule name=\"Remotely ScreenCast\"").WaitForExit(); + ProcessEx.StartHidden("netsh", $"advfirewall firewall add rule name=\"Remotely ScreenCast\" program=\"{screenCastPath}\" protocol=any dir=in enable=yes action=allow profile=Private,Domain description=\"The agent that allows screen sharing and remote control for Remotely.\"").WaitForExit(); } private void BackupDirectory() @@ -138,7 +138,7 @@ namespace Remotely.Agent.Installer.Win.Services var result = principal.IsInRole(WindowsBuiltInRole.Administrator); if (!result) { - MessageBoxWrapper.Show("Elevated privileges are required. Please restart the installer using 'Run as administrator'.", "Elevation Required", MessageBoxButton.OK, MessageBoxImage.Warning); + MessageBoxEx.Show("Elevated privileges are required. Please restart the installer using 'Run as administrator'.", "Elevation Required", MessageBoxButton.OK, MessageBoxImage.Warning); } return result; } @@ -336,7 +336,7 @@ namespace Remotely.Agent.Installer.Win.Services ProgressMessageChanged?.Invoke(this, "Installing the .NET Core runtime."); ProgressValueChanged?.Invoke(this, 0); - await Task.Run(() => { ProcessWrapper.StartHidden(targetFile, "/install /quiet /norestart").WaitForExit(); }); + await Task.Run(() => { ProcessEx.StartHidden(targetFile, "/install /quiet /norestart").WaitForExit(); }); } else { @@ -366,7 +366,7 @@ namespace Remotely.Agent.Installer.Win.Services Logger.Write("Service installed."); serv = ServiceController.GetServices().FirstOrDefault(ser => ser.ServiceName == "Remotely_Service"); - ProcessWrapper.StartHidden("cmd.exe", "/c sc.exe failure \"Remotely_Service\" reset=5 actions=restart/5000"); + ProcessEx.StartHidden("cmd.exe", "/c sc.exe failure \"Remotely_Service\" reset=5 actions=restart/5000"); } if (serv.Status != ServiceControllerStatus.Running) { diff --git a/Agent.Installer.Win/Services/MessageBoxWrapper.cs b/Agent.Installer.Win/Services/MessageBoxEx.cs similarity index 94% rename from Agent.Installer.Win/Services/MessageBoxWrapper.cs rename to Agent.Installer.Win/Services/MessageBoxEx.cs index 4670a7a4..a167e14c 100644 --- a/Agent.Installer.Win/Services/MessageBoxWrapper.cs +++ b/Agent.Installer.Win/Services/MessageBoxEx.cs @@ -7,7 +7,7 @@ using System.Windows; namespace Remotely.Agent.Installer.Win.Services { - public class MessageBoxWrapper + public static class MessageBoxEx { public static MessageBoxResult Show(string message, string caption, MessageBoxButton messageBoxButton, MessageBoxImage messageBoxImage) { diff --git a/Agent.Installer.Win/Services/ProcessWrapper.cs b/Agent.Installer.Win/Services/ProcessEx.cs similarity index 93% rename from Agent.Installer.Win/Services/ProcessWrapper.cs rename to Agent.Installer.Win/Services/ProcessEx.cs index b00c3fcd..5b08a5b3 100644 --- a/Agent.Installer.Win/Services/ProcessWrapper.cs +++ b/Agent.Installer.Win/Services/ProcessEx.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; namespace Remotely.Agent.Installer.Win.Services { - public static class ProcessWrapper + public static class ProcessEx { public static Process StartHidden(string filePath, string arguments) { diff --git a/Agent.Installer.Win/ViewModels/MainWindowViewModel.cs b/Agent.Installer.Win/ViewModels/MainWindowViewModel.cs index 7fb06aab..6edd5a7b 100644 --- a/Agent.Installer.Win/ViewModels/MainWindowViewModel.cs +++ b/Agent.Installer.Win/ViewModels/MainWindowViewModel.cs @@ -95,7 +95,7 @@ namespace Remotely.Agent.Installer.Win.ViewModels } else { - MessageBoxWrapper.Show("Log file doesn't exist.", "No Logs", MessageBoxButton.OK, MessageBoxImage.Information); + MessageBoxEx.Show("Log file doesn't exist.", "No Logs", MessageBoxButton.OK, MessageBoxImage.Information); } }); } @@ -232,7 +232,7 @@ namespace Remotely.Agent.Installer.Win.ViewModels catch (Exception ex) { Logger.Write(ex); - MessageBoxWrapper.Show("There was an error reading the installer settings. Try re-downloading the installer.", "Configuration Error", MessageBoxButton.OK, MessageBoxImage.Error); + MessageBoxEx.Show("There was an error reading the installer settings. Try re-downloading the installer.", "Configuration Error", MessageBoxButton.OK, MessageBoxImage.Error); return null; } } @@ -244,7 +244,7 @@ namespace Remotely.Agent.Installer.Win.ViewModels var result = principal.IsInRole(WindowsBuiltInRole.Administrator); if (!result) { - MessageBoxWrapper.Show("Elevated privileges are required. Please restart the installer using 'Run as administrator'.", "Elevation Required", MessageBoxButton.OK, MessageBoxImage.Warning); + MessageBoxEx.Show("Elevated privileges are required. Please restart the installer using 'Run as administrator'.", "Elevation Required", MessageBoxButton.OK, MessageBoxImage.Warning); } return result; } @@ -254,7 +254,7 @@ namespace Remotely.Agent.Installer.Win.ViewModels var result = !string.IsNullOrWhiteSpace(OrganizationID) || !string.IsNullOrWhiteSpace(ServerUrl); if (!result) { - MessageBoxWrapper.Show("Required settings are missing. Try re-downloading the installer.", "Invalid Installer", MessageBoxButton.OK, MessageBoxImage.Error); + MessageBoxEx.Show("Required settings are missing. Try re-downloading the installer.", "Invalid Installer", MessageBoxButton.OK, MessageBoxImage.Error); } return result; }