production app opens terminal on executing command on background #9719
-
I am running some exe in windows in background without opening terminal. Its perfectly working in development but in production, the terminal open and closes. Following is my sample code used in project. #[tauri::command]
fn start_server(
path: String
) -> Result<String, String> {
let mut cmd = Command::new("cmd");
cmd.args(&["/C", "start", "/B", &path]);
cmd.stdin(Stdio::null())
.stdout(Stdio::null())
.stderr(Stdio::null());
cmd.spawn()
.map_err(|e| format!("Failed to execute haive.exe: {}", e))?;
Ok("Execution initiated in background".to_string())
} from frontent will pass the path of the exe file with the exe name like |
Beta Was this translation helpful? Give feedback.
Answered by
FabianLars
May 14, 2024
Replies: 2 comments
-
Does it also happens if you use creation flags? #[tauri::command]
fn start_server(
path: String
) -> Result<String, String> {
let mut cmd = Command::new("cmd");
#[cfg(windows)]
{
use std::os::windows::process::CommandExt;
cmd.creation_flags(0x08000000); // CREATE_NO_WINDOW constant
}
cmd.args(&["/C", "start", "/B", &path]);
cmd.stdin(Stdio::null())
.stdout(Stdio::null())
.stderr(Stdio::null());
cmd.spawn()
.map_err(|e| format!("Failed to execute haive.exe: {}", e))?;
Ok("Execution initiated in background".to_string())
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
glRajkumar
-
creation_flags did solve the isses. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Does it also happens if you use creation flags?