rust 运行windows cmd命令
use std::process::Command; fn callcmd(cmdstr: &str) { Command::new("cmd") .arg("/S") .arg("/c") .arg(cmdstr) .output() .expect("-1"); } fn main() { let cmdstr = r"taskkill /f /im notepad.exe"; let cmdstr = r"schtasks /RUN /TN SAPBOT"; callcmd(cmdstr); }