fix: delete .old.exe on startup + use cmd start for new window
This commit is contained in:
parent
dbdafcfbd1
commit
a3100a872b
1 changed files with 12 additions and 3 deletions
|
|
@ -221,6 +221,13 @@ async fn main() {
|
||||||
|
|
||||||
banner();
|
banner();
|
||||||
|
|
||||||
|
// Clean up leftover .old.exe from previous self-update (Windows can't delete running exe)
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
if let Ok(exe) = std::env::current_exe() {
|
||||||
|
let old = exe.with_extension("old.exe");
|
||||||
|
let _ = std::fs::remove_file(&old);
|
||||||
|
}
|
||||||
|
|
||||||
// Single instance check
|
// Single instance check
|
||||||
if !acquire_instance_lock() {
|
if !acquire_instance_lock() {
|
||||||
display::err("❌", "Another instance of helios-remote is already running.");
|
display::err("❌", "Another instance of helios-remote is already running.");
|
||||||
|
|
@ -716,9 +723,11 @@ async fn handle_message(
|
||||||
let args: Vec<String> = std::env::args().skip(1).collect();
|
let args: Vec<String> = std::env::args().skip(1).collect();
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
{
|
{
|
||||||
use std::os::windows::process::CommandExt;
|
// Use "start" to open a new visible console window
|
||||||
const CREATE_NEW_CONSOLE: u32 = 0x00000010;
|
let exe_str = exe.to_string_lossy();
|
||||||
let _ = std::process::Command::new(&exe).args(&args).creation_flags(CREATE_NEW_CONSOLE).spawn();
|
let _ = std::process::Command::new("cmd")
|
||||||
|
.args(["/c", "start", "", &exe_str])
|
||||||
|
.spawn();
|
||||||
}
|
}
|
||||||
#[cfg(not(target_os = "windows"))]
|
#[cfg(not(target_os = "windows"))]
|
||||||
let _ = std::process::Command::new(&exe).args(&args).spawn();
|
let _ = std::process::Command::new(&exe).args(&args).spawn();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue