add existing settings
This commit is contained in:
35
src-tauri/src/tool/common.rs
Normal file
35
src-tauri/src/tool/common.rs
Normal file
@@ -0,0 +1,35 @@
|
||||
use std::process::Command;
|
||||
|
||||
pub fn kill(name: &str) -> String {
|
||||
Command::new("taskkill")
|
||||
.args(&["/IM", name, "/F"])
|
||||
.output()
|
||||
.unwrap();
|
||||
|
||||
format!("Killing {}", name)
|
||||
}
|
||||
|
||||
pub fn run_steam() -> std::io::Result<std::process::Output> {
|
||||
Command::new("cmd")
|
||||
.args(&["/C", "start", "steam://run"])
|
||||
.output()
|
||||
}
|
||||
|
||||
pub fn get_exe_path(name: &str) -> Result<String, std::io::Error> {
|
||||
let command = format!("/C wmic process where name='{}' get ExecutablePath", name);
|
||||
let args = command.split_whitespace().collect::<Vec<&str>>();
|
||||
let output = Command::new("cmd.exe").args(&args).output()?;
|
||||
|
||||
let out = String::from_utf8_lossy(&output.stdout).trim().to_string();
|
||||
|
||||
if out.contains("ExecutablePath") {
|
||||
let spt: Vec<&str> = out.split("\r\n").collect();
|
||||
if spt.len() >= 2 {
|
||||
return Ok(spt[1].to_string());
|
||||
}
|
||||
}
|
||||
Err(std::io::Error::new(
|
||||
std::io::ErrorKind::Other,
|
||||
"Failed to get executable path",
|
||||
))
|
||||
}
|
||||
Reference in New Issue
Block a user