Skip to content

Commit 05a6c6a

Browse files
committed
Eliminate use of wmic
1 parent 1dbd144 commit 05a6c6a

1 file changed

Lines changed: 6 additions & 16 deletions

File tree

core/src/core.rs

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -962,21 +962,11 @@ fn child_processes(pid: u32) -> Result<Vec<String>> {
962962

963963
#[cfg(windows)]
964964
fn child_processes(pid: u32) -> Result<Vec<String>> {
965-
let output = Command::new("wmic")
966-
.args([
967-
"process",
968-
"where",
969-
&format!("ParentProcessId={pid}"),
970-
"get",
971-
"ProcessId",
972-
])
973-
.output()?;
965+
let mut command = Command::new("powershell");
966+
command.arg(format!(
967+
r#"(Get-CimInstance -ClassName Win32_Process -Filter "ParentProcessId = {pid}").ProcessId"#
968+
));
969+
let output = command.output()?;
974970
let stdout = String::from_utf8(output.stdout)?;
975-
Ok(stdout
976-
.lines()
977-
.map(str::trim_end)
978-
.filter(|line| !line.is_empty())
979-
.skip(1)
980-
.map(ToOwned::to_owned)
981-
.collect())
971+
Ok(stdout.lines().map(|s| s.trim_end().to_owned()).collect())
982972
}

0 commit comments

Comments
 (0)