diff options
| -rw-r--r-- | src-tauri/src/core/forge.rs | 15 | ||||
| -rw-r--r-- | src-tauri/src/core/java.rs | 19 |
2 files changed, 24 insertions, 10 deletions
diff --git a/src-tauri/src/core/forge.rs b/src-tauri/src/core/forge.rs index c8bd6e4..0528b76 100644 --- a/src-tauri/src/core/forge.rs +++ b/src-tauri/src/core/forge.rs @@ -9,6 +9,8 @@ use serde::{Deserialize, Serialize}; use std::error::Error; +#[cfg(target_os = "windows")] +use std::os::windows::process::CommandExt; use std::path::PathBuf; const FORGE_PROMOTIONS_URL: &str = @@ -293,13 +295,16 @@ pub async fn run_forge_installer( // Run the installer in headless mode // The installer accepts --installClient <path> to install to a specific directory - let output = tokio::process::Command::new(java_path) - .arg("-jar") + let mut cmd = tokio::process::Command::new(java_path); + cmd.arg("-jar") .arg(&installer_path) .arg("--installClient") - .arg(game_dir) - .output() - .await?; + .arg(game_dir); + + #[cfg(target_os = "windows")] + cmd.creation_flags(0x08000000); + + let output = cmd.output().await?; // Clean up installer let _ = tokio::fs::remove_file(&installer_path).await; diff --git a/src-tauri/src/core/java.rs b/src-tauri/src/core/java.rs index ac52da6..7aa43b8 100644 --- a/src-tauri/src/core/java.rs +++ b/src-tauri/src/core/java.rs @@ -1,4 +1,6 @@ use serde::{Deserialize, Serialize}; +#[cfg(target_os = "windows")] +use std::os::windows::process::CommandExt; use std::path::PathBuf; use std::process::Command; use tauri::AppHandle; @@ -636,10 +638,12 @@ fn get_java_candidates() -> Vec<PathBuf> { let mut candidates = Vec::new(); // Check PATH first - if let Ok(output) = Command::new(if cfg!(windows) { "where" } else { "which" }) - .arg("java") - .output() - { + let mut cmd = Command::new(if cfg!(windows) { "where" } else { "which" }); + cmd.arg("java"); + #[cfg(target_os = "windows")] + cmd.creation_flags(0x08000000); + + if let Ok(output) = cmd.output() { if output.status.success() { let paths = String::from_utf8_lossy(&output.stdout); for line in paths.lines() { @@ -788,7 +792,12 @@ fn get_java_candidates() -> Vec<PathBuf> { /// Check a specific Java installation and get its version info fn check_java_installation(path: &PathBuf) -> Option<JavaInstallation> { - let output = Command::new(path).arg("-version").output().ok()?; + let mut cmd = Command::new(path); + cmd.arg("-version"); + #[cfg(target_os = "windows")] + cmd.creation_flags(0x08000000); + + let output = cmd.output().ok()?; // Java outputs version info to stderr let version_output = String::from_utf8_lossy(&output.stderr); |