kill roblox instances that are running in latest version directory

This commit is contained in:
bluepilledgreat 2024-12-27 17:54:31 +00:00
parent a91742fe51
commit 8b8d49e784

View File

@ -691,6 +691,32 @@ namespace Bloxstrap
}
}
private void KillRunningRobloxInDirectory(string path)
{
const string LOG_IDENT = "Bootstrapper::KillRunningRobloxInDirectory";
List<Process> processes = new List<Process>();
processes.AddRange(Process.GetProcessesByName(IsStudioLaunch ? "RobloxStudioBeta" : "RobloxPlayerBeta"));
processes.AddRange(Process.GetProcessesByName("RobloxCrashHandler"));
foreach (Process process in processes)
{
string? processPath = process.MainModule?.FileName;
if (processPath != null && processPath.StartsWith(path))
{
try
{
process.Kill();
}
catch (Exception ex)
{
App.Logger.WriteLine(LOG_IDENT, $"Failed to close process {process.Id} at {processPath}");
App.Logger.WriteException(LOG_IDENT, ex);
}
}
}
}
private async Task UpgradeRoblox()
{
const string LOG_IDENT = "Bootstrapper::UpgradeRoblox";
@ -706,6 +732,9 @@ namespace Bloxstrap
_isInstalling = true;
// make sure nothing is running from the latest version directory before deleting the whole directory
KillRunningRobloxInDirectory(_latestVersionDirectory);
if (Directory.Exists(_latestVersionDirectory))
{
try