Improved install logging

master
Inga 🏳‍🌈 4 years ago
parent 361d47ef01
commit c9e4e089c8
  1. 1
      RadeonResetBugFixService/Program.cs
  2. 25
      RadeonResetBugFixService/ProjectInstaller.cs

@ -105,6 +105,7 @@
ServiceHelpers.StopService(Constants.ServiceName); ServiceHelpers.StopService(Constants.ServiceName);
Console.WriteLine("Starting service..."); Console.WriteLine("Starting service...");
ServiceHelpers.StartService(Constants.ServiceName); ServiceHelpers.StartService(Constants.ServiceName);
Console.WriteLine("Service started");
} }
private static void DoUninstall() private static void DoUninstall()

@ -15,21 +15,26 @@
InitializeComponent(); InitializeComponent();
} }
private void LogMessage(string message)
{
this.Context.LogMessage($"* {message}");
}
private void serviceInstaller1_AfterInstall(object sender, InstallEventArgs e) 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); 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); RegistryHelper.SetWaitToKillServiceTimeout((int)Constants.ServiceTimeout.TotalMilliseconds);
Console.WriteLine("Disabling fast reboot"); this.LogMessage("Disabling fast reboot");
RegistryHelper.SetFastRebootStatus(false); RegistryHelper.SetFastRebootStatus(false);
Console.WriteLine("Allowing interactive services"); this.LogMessage("Allowing interactive services");
RegistryHelper.SetInteractiveServicesStatus(true); 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 wmiService = new ManagementObject($"Win32_Service.Name='{this.serviceInstaller1.ServiceName}'"))
{ {
using (var InParam = wmiService.GetMethodParameters("Change")) 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); 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(); var preshutdownOrder = RegistryHelper.GetPreshutdownOrder();
if (!preshutdownOrder.Contains(this.serviceInstaller1.ServiceName)) if (!preshutdownOrder.Contains(this.serviceInstaller1.ServiceName))
{ {
RegistryHelper.SetPreshutdownOrder(new[] { this.serviceInstaller1.ServiceName }.Concat(preshutdownOrder).ToArray()); RegistryHelper.SetPreshutdownOrder(new[] { this.serviceInstaller1.ServiceName }.Concat(preshutdownOrder).ToArray());
} }
this.LogMessage("Completed AfterInstall sequence");
} }
private void serviceInstaller1_AfterUninstall(object sender, InstallEventArgs e) 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(); var preshutdownOrder = RegistryHelper.GetPreshutdownOrder();
if (preshutdownOrder.Contains(this.serviceInstaller1.ServiceName)) if (preshutdownOrder.Contains(this.serviceInstaller1.ServiceName))
{ {
RegistryHelper.SetPreshutdownOrder(preshutdownOrder.Where((name) => name != this.serviceInstaller1.ServiceName).ToArray()); RegistryHelper.SetPreshutdownOrder(preshutdownOrder.Where((name) => name != this.serviceInstaller1.ServiceName).ToArray());
} }
this.LogMessage("Completed AfterUninstall sequence");
} }
} }
} }

Loading…
Cancel
Save