Skip to content

Commit

Permalink
Merge pull request #175 from DHancock/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
DHancock authored Aug 12, 2024
2 parents 0f53ba9 + b2d60d8 commit 2e8a5fa
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Countdown/Countdown.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
<ApplicationIcon>Resources\app.ico</ApplicationIcon>
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
<WindowsPackageType>None</WindowsPackageType>
<AssemblyVersion>3.10.1.0</AssemblyVersion>
<FileVersion>3.10.1.0</FileVersion>
<AssemblyVersion>3.10.2.0</AssemblyVersion>
<FileVersion>3.10.2.0</FileVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
3 changes: 1 addition & 2 deletions Countdown/Installer/inno_script.iss
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
21 changes: 21 additions & 0 deletions Countdown/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ static void Main(string[] args)
if ((args.Length == 1) && (args[0] == "/uninstall"))
{
DeleteAppData();
KillOtherProcesses();
}
else
{
Expand All @@ -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());
}
}
}

0 comments on commit 2e8a5fa

Please sign in to comment.