File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -962,21 +962,11 @@ fn child_processes(pid: u32) -> Result<Vec<String>> {
962962
963963#[ cfg( windows) ]
964964fn 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}
You can’t perform that action at this time.
0 commit comments