From 2f71e6778120beeb737f98e4d9e13726c11bfae2 Mon Sep 17 00:00:00 2001 From: James Brunton Date: Fri, 14 Nov 2025 13:49:58 +0000 Subject: [PATCH] Don't spawn cmd windows when checking default app in Windows --- frontend/src-tauri/src/commands/default_app.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/frontend/src-tauri/src/commands/default_app.rs b/frontend/src-tauri/src/commands/default_app.rs index bade6dba9..81e422240 100644 --- a/frontend/src-tauri/src/commands/default_app.rs +++ b/frontend/src-tauri/src/commands/default_app.rs @@ -51,9 +51,13 @@ pub fn set_as_default_pdf_handler() -> Result { #[cfg(target_os = "windows")] fn check_default_windows() -> Result { + use std::os::windows::process::CommandExt; + const CREATE_NO_WINDOW: u32 = 0x08000000; + // Query the default handler for .pdf extension let output = Command::new("cmd") .args(["/C", "assoc .pdf"]) + .creation_flags(CREATE_NO_WINDOW) .output() .map_err(|e| format!("Failed to check default app: {}", e))?; @@ -65,6 +69,7 @@ fn check_default_windows() -> Result { // Query what application handles this ProgID let output = Command::new("cmd") .args(["/C", &format!("ftype {}", prog_id)]) + .creation_flags(CREATE_NO_WINDOW) .output() .map_err(|e| format!("Failed to query file type: {}", e))?;