Skip to content

Commit

Permalink
Successfully deploy daemon
Browse files Browse the repository at this point in the history
  • Loading branch information
ahqsoftwares committed Nov 5, 2024
1 parent d2452e0 commit d77598c
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src-exe-installer/Cargo.lock

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

6 changes: 5 additions & 1 deletion src-setup/src/install/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ async fn plt_install(win: &AppWindow, client: &mut Client, files: &ReleaseData)

use crate::{
install::msi::{install_msi, install_service},
utils::{get_service_dir, get_daemon},
utils::{get_service_dir, get_daemon, kill_daemon, run_daemon},
};

win.set_msg("Downloading...".into());
Expand Down Expand Up @@ -148,6 +148,8 @@ async fn plt_install(win: &AppWindow, client: &mut Client, files: &ReleaseData)

thread::sleep(Duration::from_millis(100));

kill_daemon();

if &files.windows_user_runner != "" {
download(client, &files.windows_user_runner, daemon, |perc| {
win.set_counter(perc);
Expand All @@ -169,6 +171,8 @@ async fn plt_install(win: &AppWindow, client: &mut Client, files: &ReleaseData)

install_msi(&installer);

run_daemon(daemon);

regedit::custom_uninstall();

thread::sleep(Duration::from_secs(3));
Expand Down
12 changes: 3 additions & 9 deletions src-setup/src/uninstall/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ pub fn uninstall<T>(_: T) {}

#[cfg(windows)]
pub fn uninstall(win: AppWindow) {
use crate::utils;

unsafe {
WIN = Some(win);
};
Expand All @@ -46,15 +48,7 @@ pub fn uninstall(win: AppWindow) {
.unwrap()
.success();

let _ = Command::new("taskkill.exe")
.arg("/F")
.arg("/IM")
.arg("ahqstore_user_daemon.exe")
.creation_flags(0x08000000)
.spawn()
.unwrap()
.wait()
.unwrap();
utils::kill_daemon();

fs::remove_dir_all(r"C:\Program Files\AHQ Store");
let rem = fs::remove_file(r"C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup\ahqstore_user_daemon.exe");
Expand Down
28 changes: 28 additions & 0 deletions src-setup/src/utils/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#[cfg(windows)]
use std::{os::windows::process::CommandExt, process::Command};

use dirs::home_dir;
use lazy_static::lazy_static;

Expand Down Expand Up @@ -33,6 +36,31 @@ pub fn get_daemon() -> &'static str {
r"C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup\ahqstore_user_daemon.exe"
}

#[cfg(windows)]
pub fn kill_daemon() {
let _ = Command::new("taskkill.exe")
.arg("/F")
.arg("/IM")
.arg("ahqstore_user_daemon.exe")
.creation_flags(0x08000000)
.spawn()
.unwrap()
.wait()
.unwrap();
}

#[cfg(windows)]
pub fn run_daemon(path: &str) {
let _ = Command::new("powershell.exe")
.args(["start-process"])
.arg(path)
.creation_flags(0x08000000)
.spawn()
.unwrap()
.wait()
.unwrap();
}

pub fn get_install() -> String {
let mut path = home_dir().unwrap();
#[cfg(windows)]
Expand Down

0 comments on commit d77598c

Please sign in to comment.