Fix Windows exe launch through cmd routing (#190)

* feat: modify_command in process manager

* fix: import windows extension
This commit is contained in:
DecDuck
2026-02-26 21:48:51 +00:00
committed by GitHub
parent 33d1d28b82
commit c9ceb3f50e
2 changed files with 48 additions and 10 deletions
+40 -3
View File
@@ -1,4 +1,4 @@
use std::{fs::create_dir_all, path::PathBuf};
use std::{fs::create_dir_all, path::PathBuf, process::Command};
use client::compat::{COMPAT_INFO, UMU_LAUNCHER_EXECUTABLE};
use database::{
@@ -7,8 +7,8 @@ use database::{
use crate::{error::ProcessError, process_manager::ProcessHandler};
pub struct NativeGameLauncher;
impl ProcessHandler for NativeGameLauncher {
pub struct MacLauncher;
impl ProcessHandler for MacLauncher {
fn create_launch_process(
&self,
_meta: &DownloadableMetadata,
@@ -23,6 +23,37 @@ impl ProcessHandler for NativeGameLauncher {
fn valid_for_platform(&self, _db: &Database, _target: &Platform) -> bool {
true
}
fn modify_command(&self, _command: &mut Command) {}
}
#[allow(dead_code)]
const CREATE_NO_WINDOW: u32 = 0x08000000;
pub struct WindowsLauncher;
impl ProcessHandler for WindowsLauncher {
fn create_launch_process(
&self,
_meta: &DownloadableMetadata,
launch_command: String,
_game_version: &GameVersion,
_current_dir: &str,
_database: &Database,
) -> Result<String, ProcessError> {
Ok(format!("cmd /C \"{}\"", launch_command))
}
fn valid_for_platform(&self, _db: &Database, _target: &Platform) -> bool {
true
}
#[allow(unused_variables)]
fn modify_command(&self, command: &mut Command) {
#[cfg(target_os = "windows")]
use std::os::windows::process::CommandExt;
#[cfg(target_os = "windows")]
command.creation_flags(CREATE_NO_WINDOW);
}
}
pub struct UMUNativeLauncher;
@@ -68,6 +99,8 @@ impl ProcessHandler for UMUNativeLauncher {
};
compat_info.umu_installed
}
fn modify_command(&self, _command: &mut Command) {}
}
pub struct UMUCompatLauncher;
@@ -133,6 +166,8 @@ impl ProcessHandler for UMUCompatLauncher {
};
compat_info.umu_installed
}
fn modify_command(&self, _command: &mut Command) {}
}
pub struct AsahiMuvmLauncher;
@@ -191,4 +226,6 @@ impl ProcessHandler for AsahiMuvmLauncher {
compat_info.umu_installed
}
fn modify_command(&self, _command: &mut Command) {}
}
+8 -7
View File
@@ -28,7 +28,7 @@ use crate::{
format::DropFormatArgs,
parser::{LaunchParameters, ParsedCommand},
process_handlers::{
AsahiMuvmLauncher, NativeGameLauncher, UMUCompatLauncher, UMUNativeLauncher,
AsahiMuvmLauncher, MacLauncher, UMUCompatLauncher, UMUNativeLauncher, WindowsLauncher,
},
};
@@ -74,7 +74,7 @@ impl ProcessManager<'_> {
// Current platform to target platform
(
(Platform::Windows, Platform::Windows),
&NativeGameLauncher {} as &(dyn ProcessHandler + Sync + Send + 'static),
&WindowsLauncher {} as &(dyn ProcessHandler + Sync + Send + 'static),
),
(
(Platform::Linux, Platform::Linux),
@@ -82,7 +82,7 @@ impl ProcessManager<'_> {
),
(
(Platform::macOS, Platform::macOS),
&NativeGameLauncher {} as &(dyn ProcessHandler + Sync + Send + 'static),
&MacLauncher {} as &(dyn ProcessHandler + Sync + Send + 'static),
),
(
(Platform::Linux, Platform::Windows),
@@ -149,10 +149,7 @@ impl ProcessManager<'_> {
db_handle.applications.transient_statuses.remove(&meta);
let current_state = db_handle.applications.game_statuses.get_mut(&game_id);
if let Some(GameDownloadStatus::Installed {
install_type,
..
}) = current_state
if let Some(GameDownloadStatus::Installed { install_type, .. }) = current_state
&& let Ok(exit_code) = result
&& exit_code.success()
{
@@ -479,6 +476,8 @@ impl ProcessManager<'_> {
.env_remove("RUST_LOG")
.current_dir(launch_parameters.1);
process_handler.modify_command(&mut command);
let child = command.spawn()?;
let launch_process_handle = Arc::new(SharedChild::new(child)?);
@@ -528,4 +527,6 @@ pub trait ProcessHandler: Send + 'static {
) -> Result<String, ProcessError>;
fn valid_for_platform(&self, db: &Database, target: &Platform) -> bool;
fn modify_command(&self, command: &mut Command);
}