From b775d7853182d6a6998aa78e557aa47a2a9bcc19 Mon Sep 17 00:00:00 2001 From: David Hancock Date: Mon, 12 Aug 2024 19:38:07 +0100 Subject: [PATCH 1/2] Kill process on uninstall --- Countdown/Installer/inno_script.iss | 3 +-- Countdown/Program.cs | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Countdown/Installer/inno_script.iss b/Countdown/Installer/inno_script.iss index 7a3d93d..b414311 100644 --- a/Countdown/Installer/inno_script.iss +++ b/Countdown/Installer/inno_script.iss @@ -58,8 +58,7 @@ Name: desktopicon; Description: "{cm:CreateDesktopIcon}" Filename: "{app}\{#appExeName}"; Description: "{cm:LaunchProgram,{#appName}}"; Flags: nowait postinstall skipifsilent [UninstallRun] -Filename: "{app}\{#appExeName}"; Parameters: "/uninstall"; -Filename: powershell.exe; Parameters: "Get-Process '{#appName}' | where Path -eq '{app}\{#appExeName}' | kill -Force"; Flags: runhidden +Filename: "{app}\{#appExeName}"; Parameters: "/uninstall"; [Code] diff --git a/Countdown/Program.cs b/Countdown/Program.cs index 6ef7b14..853892b 100644 --- a/Countdown/Program.cs +++ b/Countdown/Program.cs @@ -12,6 +12,7 @@ static void Main(string[] args) if ((args.Length == 1) && (args[0] == "/uninstall")) { DeleteAppData(); + KillOtherProcesses(); } else { @@ -36,4 +37,24 @@ private static void DeleteAppData() Trace.WriteLine(ex.ToString()); } } + + private static void KillOtherProcesses() + { + try + { + Process thisProcess = Process.GetCurrentProcess(); + + foreach (Process process in Process.GetProcessesByName(thisProcess.ProcessName)) + { + if ((process.Id != thisProcess.Id) && (process.MainModule?.FileName == thisProcess.MainModule?.FileName)) + { + process.Kill(); // ensure uninstall is able to complete + } + } + } + catch (Exception ex) + { + Trace.WriteLine(ex.ToString()); + } + } } \ No newline at end of file From b2d60d88f5382fa85dfde452bae6b0a9dd90a651 Mon Sep 17 00:00:00 2001 From: David Hancock Date: Mon, 12 Aug 2024 19:38:32 +0100 Subject: [PATCH 2/2] Bump build to 3.10.2 --- Countdown/Countdown.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Countdown/Countdown.csproj b/Countdown/Countdown.csproj index c13451b..ffe6fca 100644 --- a/Countdown/Countdown.csproj +++ b/Countdown/Countdown.csproj @@ -15,8 +15,8 @@ Resources\app.ico False None - 3.10.1.0 - 3.10.1.0 + 3.10.2.0 + 3.10.2.0