wipe registry option

This commit is contained in:
SpikeHD
2022-08-26 17:53:45 -07:00
parent fa38a22117
commit bf8de40caa
6 changed files with 58 additions and 1 deletions

View File

@@ -2,6 +2,9 @@ use duct::cmd;
use ini::Ini;
use std::path::PathBuf;
#[cfg(windows)]
use registry::{Data, Hive, Security};
#[tauri::command]
pub fn run_program(path: String, args: Option<String>) {
// Without unwrap_or, this can crash when UAC prompt is denied
@@ -127,6 +130,28 @@ pub fn set_migoto_target(path: String, migoto_path: String) -> bool {
}
}
#[tauri::command]
pub fn wipe_registry(exec_name: String) {
// Fetch the 'Internet Settings' registry key.
let settings =
match Hive::CurrentUser.open(format!("Software\\miHoYo\\{}", exec_name), Security::Write) {
Ok(s) => s,
Err(e) => {
println!("Error getting registry setting: {}", e);
return;
}
};
// Wipe login cache
match settings.set_value(
"MIHOYOSDK_ADL_PROD_OVERSEA_h1158948810",
&Data::String("".parse().unwrap()),
) {
Ok(_) => (),
Err(e) => println!("Error wiping registry: {}", e),
}
}
#[cfg(windows)]
#[tauri::command]
pub fn is_elevated() -> bool {