Function e_utils::system::cmd::cmd

source ·
pub fn cmd<I, S>(
    exe: S,
    args: I,
    cwd: Option<PathBuf>,
    has_window: bool,
    _autodecode: bool,
) -> Result<CmdOutput>
where I: IntoIterator<Item = S>, S: AsRef<OsStr>,
Expand description

§命令调用 Example

use e_utils::system::cmd;
use std::path::Path;
fn main() {
    // 执行 slmgr.vbs 命令
    let output = cmd(
        "cscript",
        ["/nologo", "slmgr.vbs", "-xpr"],
        Some(Path::new("C:\\windows\\system32").to_path_buf()),
        false,
        true,
    )
    .unwrap();
    println!("out -> {:?}", output);
    // 在输出中查找激活状态
    if output.contains("Windows is activated") {
        println!("Windows 已激活");
    } else {
        println!("Windows 未激活");
    }
}