Skip to content

production app opens terminal on executing command on background #9719

Closed Answered by FabianLars
glRajkumar asked this question in Q&A
Discussion options

You must be logged in to vote

Does it also happens if you use creation flags?

#[tauri::command]
fn start_server(
    path: String
) -> Result<String, String> {
    let mut cmd = Command::new("cmd");

    #[cfg(windows)]
    {
      use std::os::windows::process::CommandExt;
      cmd.creation_flags(0x08000000); // CREATE_NO_WINDOW constant
    }

    cmd.args(&["/C", "start", "/B", &path]); 

    cmd.stdin(Stdio::null())
        .stdout(Stdio::null())
        .stderr(Stdio::null());

    cmd.spawn()
        .map_err(|e| format!("Failed to execute haive.exe: {}", e))?;

    Ok("Execution initiated in background".to_string())
}

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by glRajkumar
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants