From ccf585f8015258054b5bdd619b3bf38eb04f2da0 Mon Sep 17 00:00:00 2001 From: Helios Agent Date: Tue, 3 Mar 2026 14:59:09 +0100 Subject: [PATCH] fix(client): use powershell -NoProfile as executor to prevent $PROFILE clear --- crates/client/src/shell.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/crates/client/src/shell.rs b/crates/client/src/shell.rs index c5c5969..8eab881 100644 --- a/crates/client/src/shell.rs +++ b/crates/client/src/shell.rs @@ -1,6 +1,6 @@ /// Shell execution — each command runs in its own fresh process. -/// No persistent state, no sentinel logic, no encoding tricks. -/// stdout/stderr are captured as raw bytes and decoded with from_utf8_lossy. +/// On Windows we use powershell.exe -NoProfile so the user's $PROFILE +/// (which might run `clear`) is never loaded. use std::time::Duration; use tokio::process::Command; @@ -14,10 +14,11 @@ impl PersistentShell { pub async fn run(&mut self, command: &str) -> Result<(String, String, i32), String> { #[cfg(windows)] { - // /D = skip AutoRun registry (no user `clear` hooks) - // /C = run command and exit - let mut cmd = Command::new("cmd.exe"); - cmd.args(["/D", "/C", command]); + // -NoProfile: skip $PROFILE (prevents user's `clear` from running) + // -NonInteractive: no prompts + // -Command: run the given command string + let mut cmd = Command::new("powershell.exe"); + cmd.args(["-NoProfile", "-NonInteractive", "-Command", command]); run_captured(cmd, Duration::from_millis(TIMEOUT_MS)).await } #[cfg(not(windows))]