add existing settings

This commit is contained in:
Purp1e
2024-09-20 09:52:13 +08:00
parent 3be7e8a0b5
commit 7229e79cd4
30 changed files with 503 additions and 6 deletions

View 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",
))
}