From c9e4e089c806c842145db4d434188984aa3b75a1 Mon Sep 17 00:00:00 2001 From: Inga Lovinde <52715130+inga-lovinde@users.noreply.github.com> Date: Wed, 19 Aug 2020 00:52:27 +0300 Subject: [PATCH] Improved install logging --- RadeonResetBugFixService/Program.cs | 1 + RadeonResetBugFixService/ProjectInstaller.cs | 25 +++++++++++++------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/RadeonResetBugFixService/Program.cs b/RadeonResetBugFixService/Program.cs index b36300c..60ef90a 100644 --- a/RadeonResetBugFixService/Program.cs +++ b/RadeonResetBugFixService/Program.cs @@ -105,6 +105,7 @@ ServiceHelpers.StopService(Constants.ServiceName); Console.WriteLine("Starting service..."); ServiceHelpers.StartService(Constants.ServiceName); + Console.WriteLine("Service started"); } private static void DoUninstall() diff --git a/RadeonResetBugFixService/ProjectInstaller.cs b/RadeonResetBugFixService/ProjectInstaller.cs index 161a715..44ff94c 100644 --- a/RadeonResetBugFixService/ProjectInstaller.cs +++ b/RadeonResetBugFixService/ProjectInstaller.cs @@ -15,21 +15,26 @@ InitializeComponent(); } + private void LogMessage(string message) + { + this.Context.LogMessage($"* {message}"); + } + private void serviceInstaller1_AfterInstall(object sender, InstallEventArgs e) { - Console.WriteLine($"Creating log directory ({Constants.LogDirectory})"); + this.LogMessage($"Creating log directory ({Constants.LogDirectory})"); Directory.CreateDirectory(Constants.LogDirectory); - Console.WriteLine("Preventing Windows from killing services that take up to 300 seconds to shutdown"); + this.LogMessage("Preventing Windows from killing services that take up to 300 seconds to shutdown"); RegistryHelper.SetWaitToKillServiceTimeout((int)Constants.ServiceTimeout.TotalMilliseconds); - Console.WriteLine("Disabling fast reboot"); + this.LogMessage("Disabling fast reboot"); RegistryHelper.SetFastRebootStatus(false); - Console.WriteLine("Allowing interactive services"); + this.LogMessage("Allowing interactive services"); RegistryHelper.SetInteractiveServicesStatus(true); - Console.WriteLine("Configuring service as interactive"); + this.LogMessage("Configuring service as interactive"); using (var wmiService = new ManagementObject($"Win32_Service.Name='{this.serviceInstaller1.ServiceName}'")) { using (var InParam = wmiService.GetMethodParameters("Change")) @@ -39,25 +44,29 @@ } } - Console.WriteLine("Setting preshutdown timeout for service"); + this.LogMessage("Setting preshutdown timeout for service"); ThirdParty.ServicePreshutdownHelpers.ServicePreshutdownHelpers.SetPreShutdownTimeOut(this.serviceInstaller1.ServiceName, (uint)Constants.ServiceTimeout.TotalMilliseconds); - Console.WriteLine("Adding service to preshutdown order"); + this.LogMessage("Adding service to preshutdown order"); var preshutdownOrder = RegistryHelper.GetPreshutdownOrder(); if (!preshutdownOrder.Contains(this.serviceInstaller1.ServiceName)) { RegistryHelper.SetPreshutdownOrder(new[] { this.serviceInstaller1.ServiceName }.Concat(preshutdownOrder).ToArray()); } + + this.LogMessage("Completed AfterInstall sequence"); } private void serviceInstaller1_AfterUninstall(object sender, InstallEventArgs e) { - Console.WriteLine("Removing service from preshutdown order"); + this.LogMessage("Removing service from preshutdown order"); var preshutdownOrder = RegistryHelper.GetPreshutdownOrder(); if (preshutdownOrder.Contains(this.serviceInstaller1.ServiceName)) { RegistryHelper.SetPreshutdownOrder(preshutdownOrder.Where((name) => name != this.serviceInstaller1.ServiceName).ToArray()); } + + this.LogMessage("Completed AfterUninstall sequence"); } } }