From 62a4ab2ad3d3b730b502048e94ba313675218fb2 Mon Sep 17 00:00:00 2001 From: Jason Date: Thu, 22 Jan 2026 23:04:18 +0800 Subject: [PATCH] fix(terminal): keep Windows terminal window open after execution Use /K instead of /C flag to prevent cmd window from closing immediately after batch file execution. Also remove the buggy errorlevel check that was checking del command's return value instead of claude's. Fixes #726 --- src-tauri/src/commands/misc.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src-tauri/src/commands/misc.rs b/src-tauri/src/commands/misc.rs index 887bbd19..4f8c1c6b 100644 --- a/src-tauri/src/commands/misc.rs +++ b/src-tauri/src/commands/misc.rs @@ -729,19 +729,16 @@ echo {} claude --settings \"{}\" del \"{}\" >nul 2>&1 del \"%~f0\" >nul 2>&1 -if errorlevel 1 ( - echo. - echo Press any key to close... - pause >nul -)", +", config_path_for_batch, config_path_for_batch, config_path_for_batch ); std::fs::write(&bat_file, content).map_err(|e| format!("写入批处理文件失败: {e}"))?; // Use output() to capture errors from the start command + // Use /K instead of /C to keep the window open after execution let output = Command::new("cmd") - .args(["/C", "start", "cmd", "/C", &bat_file.to_string_lossy()]) + .args(["/C", "start", "cmd", "/K", &bat_file.to_string_lossy()]) .creation_flags(CREATE_NO_WINDOW) .output() .map_err(|e| format!("执行 cmd 失败: {e}"))?;