diff --git a/Cargo.lock b/Cargo.lock index 1e5bec1..b12d0af 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1373,9 +1373,9 @@ dependencies = [ [[package]] name = "win32utils" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4531a565ad6375783b6a9f5fdddfa3c92125aefd8de98e48b982b1671c0b341f" +checksum = "29e4e0a8dbddd5ce90484e9561652b5df02d4e54452251942e47468befcd1565" dependencies = [ "windows 0.58.0", ] diff --git a/Cargo.toml b/Cargo.toml index 970aba4..3b25356 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,8 +12,7 @@ serde-xml-rs = "0.6.0" sysinfo = "0.31.2" [target.'cfg(windows)'.dependencies] -# win32utils = "0.2.0" -win32utils = "0.3.0" +win32utils = "0.4.0" [target.'cfg(windows)'.dependencies.windows] version = "0.58.0" diff --git a/src/main.rs b/src/main.rs index 10fbb17..c478982 100644 --- a/src/main.rs +++ b/src/main.rs @@ -245,7 +245,16 @@ fn add_to_startup() { // check if the program is already in startup match win32utils::registry::exists(win32utils::registry::HKEY::CurrentUser, subkey, name) { - Ok(true) => return, + Ok(true) => { + let path = std::env::current_exe().unwrap(); + let existing_path = win32utils::registry::read_string(win32utils::registry::HKEY::CurrentUser, subkey, name).unwrap_or_default(); + + println!("Existing path: {}", existing_path); + + if existing_path == path.to_string_lossy() { + return; + } + } Ok(false) => {} Err(error) => { eprintln!("Failed to check registry key: {}", error.to_string());