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.
|
/// Shell execution — each command runs in its own fresh process.
|
||||||
/// No persistent state, no sentinel logic, no encoding tricks.
|
/// On Windows we use powershell.exe -NoProfile so the user's $PROFILE
|
||||||
/// stdout/stderr are captured as raw bytes and decoded with from_utf8_lossy.
|
/// (which might run `clear`) is never loaded.
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use tokio::process::Command;
|
use tokio::process::Command;
|
||||||
|
|
||||||
|
|
@ -14,10 +14,11 @@ impl PersistentShell {
|
||||||
pub async fn run(&mut self, command: &str) -> Result<(String, String, i32), String> {
|
pub async fn run(&mut self, command: &str) -> Result<(String, String, i32), String> {
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
{
|
{
|
||||||
// /D = skip AutoRun registry (no user `clear` hooks)
|
// -NoProfile: skip $PROFILE (prevents user's `clear` from running)
|
||||||
// /C = run command and exit
|
// -NonInteractive: no prompts
|
||||||
let mut cmd = Command::new("cmd.exe");
|
// -Command: run the given command string
|
||||||
cmd.args(["/D", "/C", command]);
|
let mut cmd = Command::new("powershell.exe");
|
||||||
|
cmd.args(["-NoProfile", "-NonInteractive", "-Command", command]);
|
||||||
run_captured(cmd, Duration::from_millis(TIMEOUT_MS)).await
|
run_captured(cmd, Duration::from_millis(TIMEOUT_MS)).await
|
||||||
}
|
}
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue