Skip to content

Commit

Permalink
fix: hide the console window in Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
amrbashir committed Mar 20, 2023
1 parent f36f37a commit bc75d84
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,24 @@ use std::{

use std::os::windows::process::CommandExt;

const CREATE_NO_WINDOW: u32 = 0x08000000;

pub fn commands<T: AsRef<OsStr>>(path: T) -> Vec<Command> {
let mut cmd = Command::new("cmd");
cmd.arg("/c")
.arg("start")
.raw_arg("\"\"")
.raw_arg(wrap_in_quotes(path));
.raw_arg(wrap_in_quotes(path))
.creation_flags(CREATE_NO_WINDOW);
vec![cmd]
}

pub fn with_command<T: AsRef<OsStr>>(path: T, app: impl Into<String>) -> Command {
let mut cmd = Command::new("cmd");
cmd.arg("/c")
.raw_arg(app.into())
.raw_arg(wrap_in_quotes(path));
.raw_arg(wrap_in_quotes(path))
.creation_flags(CREATE_NO_WINDOW);
cmd
}

Expand Down

0 comments on commit bc75d84

Please sign in to comment.