Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rust调用windows cmd执行命令 #2

Open
wuyuedefeng opened this issue Nov 5, 2020 · 0 comments
Open

rust调用windows cmd执行命令 #2

wuyuedefeng opened this issue Nov 5, 2020 · 0 comments

Comments

@wuyuedefeng
Copy link
Member

wuyuedefeng commented Nov 5, 2020

#![windows_subsystem = "windows"]

use std::process::{Command,Stdio};
use std::os::windows::process::CommandExt;

fn main (){
        // CREATE_NO_WINDOW: 0x08000000 https://docs.microsoft.com/en-us/windows/win32/procthread/process-creation-flags
	let output = Command::new("cmd").creation_flags(0x08000000).arg("/c").arg("ping baidu.com")
	.stdout(Stdio::piped()).output().expect("cmd exec error!");
	println!("{}", String::from_utf8_lossy(&output.stdout));
}
@wuyuedefeng wuyuedefeng changed the title 在 VSCode 中配置 Rust 工程 rust调用windows cmd执行命令 Jan 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant