Skip to content

Commit

Permalink
feat: update startup path when neede (#7)
Browse files Browse the repository at this point in the history
Closes #7
  • Loading branch information
The-Noah committed Aug 23, 2024
1 parent 5fb2b7f commit de1775c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
11 changes: 10 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit de1775c

Please sign in to comment.