Skip to content

Instantly share code, notes, and snippets.

@SCP002
Created November 29, 2023 18:48
Show Gist options
  • Save SCP002/e3693509d14acd86680ad66e44d149be to your computer and use it in GitHub Desktop.
Save SCP002/e3693509d14acd86680ad66e44d149be to your computer and use it in GitHub Desktop.
Rust: Start windows process in new console using CREATE_NEW_CONSOLE creation flag.
// Add to your Cargo.toml:
// [dependencies]
// subprocess = { version = "0.2.10", git = "https://github.com/SCP002/rust-subprocess.git" }
use subprocess::Exec;
fn main() {
let exit_status = Exec::cmd("my-executable-name")
.arg("arg1")
.creation_flags(0x00000010) // CREATE_NEW_CONSOLE
.startup_info_flags(0)
.join()
.unwrap();
println!("Exit status: {:?}", exit_status);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment