mirror of
https://github.com/okieselbach/AutopilotMonitor.git
synced 2026-10-24 20:53:06 +00:00
fix summary cleanup - wrong CWD caused open handle and no cleanup
This commit is contained in:
@@ -1 +1 @@
|
||||
420
|
||||
421
|
||||
|
||||
@@ -189,12 +189,19 @@ namespace AutopilotMonitor.SummaryDialog
|
||||
|
||||
Log($"SelfCleanup: spawning PowerShell to delete '{exeDir}' after PID {pid} exits");
|
||||
|
||||
// WorkingDirectory MUST NOT be exeDir — on Windows a process cannot
|
||||
// delete a directory that is its own CWD. When the agent launches
|
||||
// the dialog via CreateProcessAsUser it sets CWD = exeDir, and
|
||||
// PowerShell would inherit that, making Remove-Item silently fail.
|
||||
var safeDir = Environment.GetFolderPath(Environment.SpecialFolder.System);
|
||||
|
||||
Process.Start(new ProcessStartInfo
|
||||
{
|
||||
FileName = psExe,
|
||||
Arguments = $"-NoProfile -NonInteractive -WindowStyle Hidden -EncodedCommand {encoded}",
|
||||
UseShellExecute = true,
|
||||
WindowStyle = ProcessWindowStyle.Hidden
|
||||
WindowStyle = ProcessWindowStyle.Hidden,
|
||||
WorkingDirectory = safeDir
|
||||
});
|
||||
|
||||
Log("SelfCleanup: cleanup process started");
|
||||
|
||||
Reference in New Issue
Block a user