diff --git a/src-tauri/src/commands/misc.rs b/src-tauri/src/commands/misc.rs index 7e3337dc..fb6b980f 100644 --- a/src-tauri/src/commands/misc.rs +++ b/src-tauri/src/commands/misc.rs @@ -813,12 +813,15 @@ fn resolve_launch_cwd(cwd: Option) -> Result, String> { return Err(format!("选择的路径不是文件夹: {}", resolved.display())); } - // Strip Windows extended-length prefix (\\?\) that canonicalize produces, + // Strip Windows extended-length prefix that canonicalize produces, // as it can break batch scripts and other shell commands. + // Special-case \\?\UNC\server\share -> \\server\share for network/WSL paths. #[cfg(target_os = "windows")] let resolved = { let s = resolved.to_string_lossy(); - if let Some(stripped) = s.strip_prefix(r"\\?\") { + if let Some(unc) = s.strip_prefix(r"\\?\UNC\") { + PathBuf::from(format!(r"\\{unc}")) + } else if let Some(stripped) = s.strip_prefix(r"\\?\") { PathBuf::from(stripped) } else { resolved