From 16e9e716b62c164e6c02dea2381497a154f2d96a Mon Sep 17 00:00:00 2001 From: fufesou <13586388+fufesou@users.noreply.github.com> Date: Sun, 27 Apr 2025 12:04:05 +0800 Subject: [PATCH] fix: check server running on Windows (#11578) Signed-off-by: fufesou --- src/core_main.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/core_main.rs b/src/core_main.rs index 1c4d66c61..c58835da9 100644 --- a/src/core_main.rs +++ b/src/core_main.rs @@ -77,7 +77,14 @@ pub fn core_main() -> Option> { } #[cfg(any(target_os = "linux", target_os = "windows"))] if args.is_empty() { - if crate::check_process("--server", false) && !crate::check_process("--tray", true) { + #[cfg(target_os = "linux")] + let is_server_running = crate::check_process("--server", false); + // We can use `crate::check_process("--server", false)` on Windows. + // Because `--server` process is the System user's process. We can't get the arguments in `check_process()`. + // We can assume that self service running means the server is also running on Windows. + #[cfg(target_os = "windows")] + let is_server_running = crate::platform::is_self_service_running(); + if is_server_running && !crate::check_process("--tray", true) { #[cfg(target_os = "linux")] hbb_common::allow_err!(crate::platform::check_autostart_config()); hbb_common::allow_err!(crate::run_me(vec!["--tray"]));