diff --git a/src-tauri/src/proxy.rs b/src-tauri/src/proxy.rs index ec29d69..f9018fe 100644 --- a/src-tauri/src/proxy.rs +++ b/src-tauri/src/proxy.rs @@ -242,6 +242,7 @@ pub fn install_ca_files(cert_path: &Path) { crate::system_helpers::run_command( "certutil", vec!["-user", "-addstore", "Root", cert_path.to_str().unwrap()], + None, ); println!("Installed certificate."); } diff --git a/src-tauri/src/system_helpers.rs b/src-tauri/src/system_helpers.rs index 778bcef..ab070d2 100644 --- a/src-tauri/src/system_helpers.rs +++ b/src-tauri/src/system_helpers.rs @@ -26,13 +26,28 @@ pub fn run_program_relative(path: String, args: Option) { } #[tauri::command] -pub fn run_command(program: &str, args: Vec<&str>) { +pub fn run_command(program: &str, args: Vec<&str>, relative: Option) { let prog = program.to_string(); let args = args.iter().map(|s| s.to_string()).collect::>(); // Commands should not block (this is for the reshade injector mostly) std::thread::spawn(move || { + // Save the current working directory + let cwd = std::env::current_dir().unwrap(); + + if relative.unwrap_or(false) { + // Set the new working directory to the path before the executable + let mut path_buf = std::path::PathBuf::from(&prog); + path_buf.pop(); + + // Set new working directory + std::env::set_current_dir(&path_buf).unwrap(); + } + cmd(prog, args).run().unwrap(); + + // Restore the original working directory + std::env::set_current_dir(&cwd).unwrap(); }); } diff --git a/src/ui/components/menu/ExtrasMenu.tsx b/src/ui/components/menu/ExtrasMenu.tsx index b3281f9..900b304 100644 --- a/src/ui/components/menu/ExtrasMenu.tsx +++ b/src/ui/components/menu/ExtrasMenu.tsx @@ -115,6 +115,7 @@ export class ExtrasMenu extends React.Component { await invoke('run_command', { program: config.reshade_path, args: [await getGameExecutable()], + relative: true, }) }