43 lines
1.5 KiB
C#
Raw Normal View History

2023-11-09 10:32:52 -05:00
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)
{
}
2024-05-01 10:31:55 -04:00
2023-11-09 10:32:52 -05:00
public async override Task<PreCheckResult> CheckOperation()
{
var eftLauncherProcs = Process.GetProcessesByName("BsgLauncher");
return eftLauncherProcs.Length == 0
? PreCheckResult.FromSuccess("Eft launcher is closed")
: PreCheckResult.FromError("Your BSG launcher is open. Please close it to continue installing SPT",
2024-05-01 10:31:55 -04:00
"Kill EFT Launcher Processes",
2023-11-09 10:32:52 -05:00
() =>
{
2024-05-01 10:31:55 -04:00
var bsgLauncherProcs = Process.GetProcessesByName("BsgLauncher");
foreach (var proc in bsgLauncherProcs)
2023-11-09 10:32:52 -05:00
{
2024-05-01 10:31:55 -04:00
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}");
}
2023-11-09 10:32:52 -05:00
}
2024-05-01 10:31:55 -04:00
RequestReevaluation();
});
2023-11-09 10:32:52 -05:00
}
}