From 7aee1d57c70bcbc1cd77679133bd1b5b2debf01c Mon Sep 17 00:00:00 2001 From: Oliver Kieselbach Date: Mon, 9 Mar 2026 20:18:09 +0100 Subject: [PATCH] fix summary cleanup --- src/Agent/AutopilotMonitor.Agent/buildcounter.txt | 2 +- src/Agent/AutopilotMonitor.SummaryDialog/App.xaml.cs | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Agent/AutopilotMonitor.Agent/buildcounter.txt b/src/Agent/AutopilotMonitor.Agent/buildcounter.txt index 61ab674d..fae51388 100644 --- a/src/Agent/AutopilotMonitor.Agent/buildcounter.txt +++ b/src/Agent/AutopilotMonitor.Agent/buildcounter.txt @@ -1 +1 @@ -378 +381 diff --git a/src/Agent/AutopilotMonitor.SummaryDialog/App.xaml.cs b/src/Agent/AutopilotMonitor.SummaryDialog/App.xaml.cs index c8a3aa8f..ba6b94f6 100644 --- a/src/Agent/AutopilotMonitor.SummaryDialog/App.xaml.cs +++ b/src/Agent/AutopilotMonitor.SummaryDialog/App.xaml.cs @@ -170,9 +170,12 @@ namespace AutopilotMonitor.SummaryDialog // PowerShell Wait-Process: waits for our actual process exit (no polling), // then short delay for file handle cleanup, then Remove-Item. + // Two-pass delete: -Recurse clears contents, second call removes the + // now-empty folder (Windows/PowerShell timing issue can leave it behind). var psScript = $"Wait-Process -Id {pid} -Timeout 30 -ErrorAction SilentlyContinue; " + $"Start-Sleep -Seconds 2; " + - $"Remove-Item -LiteralPath '{exeDir}' -Recurse -Force -ErrorAction SilentlyContinue"; + $"Remove-Item -LiteralPath '{exeDir}' -Recurse -Force -ErrorAction SilentlyContinue; " + + $"Remove-Item -LiteralPath '{exeDir}' -Force -ErrorAction SilentlyContinue"; var encoded = Convert.ToBase64String(Encoding.Unicode.GetBytes(psScript)); // Full path to powershell.exe — don't rely on PATH resolution