From 7f631611fdd32e84d5d554a5836e4cbdaf8eac60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pascal=20Andr=C3=A9?= Date: Mon, 16 Mar 2026 01:44:58 +0100 Subject: [PATCH] fix(tauri): hide Windows CLI console window Set CREATE_NO_WINDOW on the spawned local CLI process so the packaged Windows Tauri app does not flash an extra console window when it launches Node. --- packages/tauri-app/src-tauri/src/cli_manager.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/tauri-app/src-tauri/src/cli_manager.rs b/packages/tauri-app/src-tauri/src/cli_manager.rs index d4074b1d..4d96f540 100644 --- a/packages/tauri-app/src-tauri/src/cli_manager.rs +++ b/packages/tauri-app/src-tauri/src/cli_manager.rs @@ -17,10 +17,23 @@ use std::thread; use std::time::{Duration, Instant}; use tauri::{webview::cookie::Cookie, AppHandle, Emitter, Manager, Url}; +#[cfg(windows)] +use std::os::windows::process::CommandExt; + +#[cfg(windows)] +const CREATE_NO_WINDOW: u32 = 0x08000000; + fn log_line(message: &str) { println!("[tauri-cli] {message}"); } +fn configure_spawn(command: &mut Command) { + #[cfg(windows)] + { + command.creation_flags(CREATE_NO_WINDOW); + } +} + fn workspace_root() -> Option { std::env::current_dir().ok().and_then(|mut dir| { for _ in 0..3 { @@ -456,6 +469,7 @@ impl CliProcessManager { .env("ELECTRON_RUN_AS_NODE", "1") .stdout(Stdio::piped()) .stderr(Stdio::piped()); + configure_spawn(&mut c); if let Some(ref cwd) = cwd { c.current_dir(cwd); } @@ -468,6 +482,7 @@ impl CliProcessManager { .env("ELECTRON_RUN_AS_NODE", "1") .stdout(Stdio::piped()) .stderr(Stdio::piped()); + configure_spawn(&mut c); if let Some(ref cwd) = cwd { c.current_dir(cwd); }