fix(client): use powershell -NoProfile as executor to prevent $PROFILE clear
This commit is contained in:
parent
0e8f2b11e8
commit
ccf585f801
1 changed files with 7 additions and 6 deletions
|
|
@ -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))]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue