aboutsummaryrefslogtreecommitdiff
path: root/src-tauri/src/util.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src-tauri/src/util.rs')
-rw-r--r--src-tauri/src/util.rs23
1 files changed, 22 insertions, 1 deletions
diff --git a/src-tauri/src/util.rs b/src-tauri/src/util.rs
index 0f32ecb5..f1ba6b8a 100644
--- a/src-tauri/src/util.rs
+++ b/src-tauri/src/util.rs
@@ -2,7 +2,7 @@
use anyhow::{Context, Result};
use serde::{Deserialize, Serialize};
-use sysinfo::SystemExt;
+use sysinfo::{ProcessExt, SystemExt};
use zip::ZipArchive;
use crate::constants::{APP_USER_AGENT, MASTER_SERVER_URL, SERVER_BROWSER_ENDPOINT};
@@ -64,6 +64,27 @@ pub async fn get_server_player_count() -> Result<(i32, usize), String> {
Ok((total_player_count, server_count))
}
+#[tauri::command]
+pub async fn kill_northstar() -> Result<(), String> {
+ if !check_northstar_running() {
+ return Err("Northstar is not running".to_string());
+ }
+
+ let s = sysinfo::System::new_all();
+
+ for process in s.processes_by_exact_name("Titanfall2.exe") {
+ log::info!("Killing Process {}", process.pid());
+ process.kill();
+ }
+
+ for process in s.processes_by_exact_name("NorthstarLauncher.exe") {
+ log::info!("Killing Process {}", process.pid());
+ process.kill();
+ }
+
+ Ok(())
+}
+
/// Copied from `papa` source code and modified
///Extract N* zip file to target game path
// fn extract(ctx: &Ctx, zip_file: File, target: &Path) -> Result<()> {