Skip to content

Commit d7b2214

Browse files
milispclaude
andcommitted
fix: hide console window for command existence checks on Windows
Improve command existence checking by: - Adding CREATE_NO_WINDOW flag on Windows to prevent console flash - Using proper Windows-specific imports with conditional compilation - Redirecting stdio streams to null to suppress output 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 4f64109 commit d7b2214

File tree

1 file changed

+33
-7
lines changed

1 file changed

+33
-7
lines changed

tauri-app/src-tauri/src/installer.rs

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
use serde::{Deserialize, Serialize};
22
use std::process::Command;
33

4+
#[cfg(windows)]
5+
use tokio::process::Command as TokioCommand;
6+
47
mod uv_installer;
58

69
#[derive(Debug, Serialize, Deserialize)]
@@ -236,16 +239,39 @@ async fn is_command_available(cmd: &str) -> bool {
236239
.unwrap_or(false)
237240
}
238241

239-
// Fixed: Improved command existence check
242+
// Fixed: Improved command existence check with hidden window on Windows
240243
#[tauri::command]
241244
pub async fn check_command_exists(command: String) -> Result<bool, String> {
242245
let exists = match std::env::consts::OS {
243-
"windows" => tokio::process::Command::new("cmd")
244-
.args(&["/C", "where", &command])
245-
.output()
246-
.await
247-
.map(|output| output.status.success())
248-
.unwrap_or(false),
246+
"windows" => {
247+
use std::process::Stdio;
248+
#[cfg(windows)]
249+
{
250+
use std::os::windows::process::CommandExt;
251+
tokio::process::Command::new("cmd")
252+
.args(&["/C", "where", &command])
253+
.stdout(Stdio::null())
254+
.stderr(Stdio::null())
255+
.stdin(Stdio::null())
256+
.creation_flags(0x08000000) // CREATE_NO_WINDOW
257+
.output()
258+
.await
259+
.map(|output| output.status.success())
260+
.unwrap_or(false)
261+
}
262+
#[cfg(not(windows))]
263+
{
264+
tokio::process::Command::new("cmd")
265+
.args(&["/C", "where", &command])
266+
.stdout(Stdio::null())
267+
.stderr(Stdio::null())
268+
.stdin(Stdio::null())
269+
.output()
270+
.await
271+
.map(|output| output.status.success())
272+
.unwrap_or(false)
273+
}
274+
},
249275
_ => tokio::process::Command::new("which")
250276
.arg(&command)
251277
.output()

0 commit comments

Comments
 (0)