Skip to content

Commit

Permalink
Improved install logging
Browse files Browse the repository at this point in the history
  • Loading branch information
inga-lovinde committed Aug 18, 2020
1 parent 361d47e commit c9e4e08
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
1 change: 1 addition & 0 deletions RadeonResetBugFixService/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ private static void DoInstall()
ServiceHelpers.StopService(Constants.ServiceName);
Console.WriteLine("Starting service...");
ServiceHelpers.StartService(Constants.ServiceName);
Console.WriteLine("Service started");
}

private static void DoUninstall()
Expand Down
25 changes: 17 additions & 8 deletions RadeonResetBugFixService/ProjectInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,26 @@ public ProjectInstaller()
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"))
Expand All @@ -39,25 +44,29 @@ private void serviceInstaller1_AfterInstall(object sender, InstallEventArgs e)
}
}

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");
}
}
}

0 comments on commit c9e4e08

Please sign in to comment.
  NODES
COMMUNITY 1
Note 1
Project 7
USERS 1