main.rs
use std::process::Command;
fn main() {
let output = if cfg!(target_os = "windows") {
Command::new("cmd")
.arg("/C")
.arg("rundll32 sysdm.cpl,EditEnvironmentVariables")
.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,hello,实例,Command,expect,arg,output,环境变量,rust
From: https://www.cnblogs.com/Nazorine/p/16705652.html