main.rs
#![windows_subsystem = "windows"]
use std::process::Command;
use std::os::windows::process::CommandExt;
fn main() {
let output = if cfg!(target_os = "windows") {
Command::new("cmd")
.creation_flags(0x08000000)
.arg("/C")
.arg("lusrmgr")
.output()
.expect("failed to execute process")
} else {
Command::new("sh")
.arg("-c")
.arg("echo hello")
.output()
.expect("failed to execute process")
};
let hello = output.stdout;
println!("{:?}", hello);
}
标签:process,本地用户,windows,实例,Command,arg,output,hello,rust
From: https://www.cnblogs.com/Nazorine/p/16706095.html