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);
}

  

posted @ 2023-11-28 14:05  CrossPython  阅读(231)  评论(0编辑  收藏  举报