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