首页 > 其他分享 >实例-rust-打开本地用户和组

实例-rust-打开本地用户和组

时间:2022-09-18 22:45:29浏览次数:68  
标签:process 本地用户 windows 实例 Command arg output hello rust

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

相关文章

  • rust执行cmd命令隐藏窗口
    https://blog.csdn.net/weixin_35894173/article/details/112282032https://rustcc.cn/article?id=f1630b61-4637-4e80-8414-8a921af50d68主要原理是,通过函数creation_fl......
  • 实例-rust-打开计算器
    https://rust.ffactory.org/std/process/struct.Command.html进程生成器,提供对如何生成新进程的细粒度控制。可以使用Command::new(program)生成默认配置,其中program......
  • 实例-rust-打开环境变量
    main.rsusestd::process::Command;fnmain(){letoutput=ifcfg!(target_os="windows"){Command::new("cmd").arg("/C")......
  • rust
    https://juejin.cn/post/6844903821307723789externcrate关键字用于导入依赖库,你只需将其添加到主文件中,应用程序的任何源文件就都可以引用它了。use部分则是指你将在......
  • Rust 学习笔记
    学习资料rust程序语言英文:https://doc.rust-lang.org/book/title-page.html中文:https://kaisery.gitbooks.io/trpl-zh-cn/content/ch02-00-guessing-game-tutorial.ht......
  • 深入剖析Java虚拟机:源码剖析与实例详解(基础卷) pdf
    高清扫描版下载链接:https://pan.baidu.com/s/10P_9A-09hqKl-2Y1tLJIoA点击这里获取提取码 ......
  • 实例-rust-将数据写入json文件
    Cargo.toml[package]name="rust-example5"version="0.1.0"edition="2021"#Seemorekeysandtheirdefinitionsathttps://doc.rust-lang.org/cargo/refere......
  • 实例-rust-string和bytes转换
    Cargo.toml[package]name="rust-example9"version="0.1.0"edition="2021"#Seemorekeysandtheirdefinitionsathttps://doc.rust-lang.org/cargo/refere......
  • 实例-rust-将struct写入json文件
    cargo.toml[package]name="rust-example5"version="0.1.0"edition="2021"#Seemorekeysandtheirdefinitionsathttps://doc.rust-lang.org/cargo/refere......
  • 实例-rust-从json文件中读取数据并将输出写入json文件
    Cargo.toml[package]name="rust-example5"version="0.1.0"edition="2021"#Seemorekeysandtheirdefinitionsathttps://doc.rust-lang.org/cargo/refere......