From 8b8d49e784e92c15feba4d434bbb0d57b148868d Mon Sep 17 00:00:00 2001 From: bluepilledgreat <97983689+bluepilledgreat@users.noreply.github.com> Date: Fri, 27 Dec 2024 17:54:31 +0000 Subject: [PATCH] kill roblox instances that are running in latest version directory --- Bloxstrap/Bootstrapper.cs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/Bloxstrap/Bootstrapper.cs b/Bloxstrap/Bootstrapper.cs index aa71eff..010b16c 100644 --- a/Bloxstrap/Bootstrapper.cs +++ b/Bloxstrap/Bootstrapper.cs @@ -691,6 +691,32 @@ namespace Bloxstrap } } + private void KillRunningRobloxInDirectory(string path) + { + const string LOG_IDENT = "Bootstrapper::KillRunningRobloxInDirectory"; + + List processes = new List(); + 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