Skip to content

Instantly share code, notes, and snippets.

@TheOnlyArtz
Created January 27, 2022 09:03
Show Gist options
  • Save TheOnlyArtz/df579c6ab6e7c1538498acaf5bdc09ab to your computer and use it in GitHub Desktop.
Save TheOnlyArtz/df579c6ab6e7c1538498acaf5bdc09ab to your computer and use it in GitHub Desktop.
use std::{process::{Command , Stdio}, time::{Duration, Instant}};
#[cfg(target_os = "windows")]
use std::os::windows::process::CommandExt;
fn main() {
let mut child = Command::new("cmd")
.args(["/c", "schtasks"])
.creation_flags(0x08000000)
.stdout(Stdio::piped())
.spawn()
.unwrap();
// loop {
// std::thread::sleep(Duration::from_secs(1));
// println!("Iteration!");
// match child.try_wait() {
// Ok(Some(status)) => println!("exited with: {}", status),
// Ok(None) => {
// println!("status not ready yet, let's really wait");
// let res = child.wait();
// println!("result: {:?}", res);
// }
// Err(e) => println!("error attempting to wait: {}", e),
// }
// }
println!("Result: {:?}", child.wait_with_output());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment