open jar and game properly

This commit is contained in:
SpikeHD
2022-05-13 21:15:24 -07:00
parent a6b5891857
commit 10e9529509
5 changed files with 57 additions and 5 deletions

View File

@@ -3,6 +3,7 @@ all(not(debug_assertions), target_os = "windows"),
windows_subsystem = "windows"
)]
use std::process::Command;
use open;
mod downloader;
@@ -15,6 +16,7 @@ fn main() {
connect,
disconnect,
run_program,
run_jar,
downloader::download_file,
downloader::stop_download,
lang::get_lang
@@ -44,5 +46,17 @@ fn disconnect() {
#[tauri::command]
fn run_program(path: String) {
// Open the program from the specified path.
open::that(path).expect("Failed to open program");
match open::that(path) {
Ok(_) => (),
Err(e) => println!("Failed to open program: {}", e),
};
}
#[tauri::command]
fn run_jar(path: String) {
// Open the program from the specified path.
match open::with("/k java -jar ".to_string() + &path, "C:\\Windows\\System32\\cmd.exe") {
Ok(_) => (),
Err(e) => println!("Failed to open jar ({}): {}", &path, e),
};
}