add eft launcher closed precheck
This commit is contained in:
parent
ad37a15a92
commit
a54bee78e1
@ -0,0 +1,43 @@
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
using Serilog;
|
||||
using SPTInstaller.Models;
|
||||
|
||||
namespace SPTInstaller.Installer_Tasks.PreChecks;
|
||||
|
||||
public class EftLauncherPreCheck : PreCheckBase
|
||||
{
|
||||
public EftLauncherPreCheck() : base("EFT Launcher Closed", true)
|
||||
{
|
||||
}
|
||||
|
||||
public async override Task<PreCheckResult> CheckOperation()
|
||||
{
|
||||
var eftLauncherProcs = Process.GetProcessesByName("BsgLauncher");
|
||||
|
||||
return eftLauncherProcs.Length == 0
|
||||
? PreCheckResult.FromSuccess("Eft launcher is closed")
|
||||
: PreCheckResult.FromError("Eft launcher is open. Please close it to install SPT",
|
||||
"Kill EFT Launcher Processes",
|
||||
() =>
|
||||
{
|
||||
var bsgLauncherProcs = Process.GetProcessesByName("BsgLauncher");
|
||||
|
||||
foreach (var proc in bsgLauncherProcs)
|
||||
{
|
||||
try
|
||||
{
|
||||
proc.Kill();
|
||||
proc.WaitForExit();
|
||||
Log.Information($"Killed Proc: {proc.ProcessName}#{proc.Id}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failed to kill proc: {proc.ProcessName}#{proc.Id}");
|
||||
}
|
||||
}
|
||||
|
||||
RequestReevaluation();
|
||||
});
|
||||
}
|
||||
}
|
@ -34,8 +34,8 @@ internal class Program
|
||||
#if !TEST
|
||||
ServiceHelper.Register<PreCheckBase, NetFramework472PreCheck>();
|
||||
ServiceHelper.Register<PreCheckBase, NetCore6PreCheck>();
|
||||
|
||||
ServiceHelper.Register<PreCheckBase, FreeSpacePreCheck>();
|
||||
ServiceHelper.Register<PreCheckBase, EftLauncherPreCheck>();
|
||||
|
||||
ServiceHelper.Register<InstallerTaskBase, InitializationTask>();
|
||||
ServiceHelper.Register<InstallerTaskBase, ReleaseCheckTask>();
|
||||
|
Loading…
x
Reference in New Issue
Block a user