diff --git a/src/lang/en.rs b/src/lang/en.rs index 7c95f8abb..72aa45853 100644 --- a/src/lang/en.rs +++ b/src/lang/en.rs @@ -34,5 +34,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("uac_warning", "Temporarily denied access due to elevation request, please wait for the remote user to accept the UAC dialog. To avoid this problem, it is recommended to install the software on the remote device or run it with administrator privileges."), ("elevated_foreground_window_warning", "Temporarily unable to use the mouse and keyboard, because the current window of the remote desktop requires higher privilege to operate, you can request the remote user to minimize the current window. To avoid this problem, it is recommended to install the software on the remote device or run it with administrator privileges."), ("JumpLink", "View"), + ("Stop service", "Stop Service"), ].iter().cloned().collect(); } diff --git a/src/platform/windows.rs b/src/platform/windows.rs index 53fb60bd8..3fc25e208 100644 --- a/src/platform/windows.rs +++ b/src/platform/windows.rs @@ -21,7 +21,10 @@ use winapi::{ errhandlingapi::GetLastError, handleapi::CloseHandle, minwinbase::STILL_ACTIVE, - processthreadsapi::{GetCurrentProcess, GetExitCodeProcess, OpenProcess, OpenProcessToken}, + processthreadsapi::{ + GetCurrentProcess, GetCurrentProcessId, GetExitCodeProcess, OpenProcess, + OpenProcessToken, + }, securitybaseapi::GetTokenInformation, shellapi::ShellExecuteA, winbase::*, @@ -905,7 +908,7 @@ pub fn update_me() -> ResultType<()> { chcp 65001 sc stop {app_name} taskkill /F /IM {broker_exe} - taskkill /F /IM {app_name}.exe + taskkill /F /IM {app_name}.exe /FI \"PID ne {cur_pid}\" {copy_exe} \"{src_exe}\" --extract \"{path}\" sc start {app_name} @@ -917,6 +920,7 @@ pub fn update_me() -> ResultType<()> { path = path, app_name = crate::get_app_name(), lic = register_licence(), + cur_pid = get_current_pid(), ); std::thread::sleep(std::time::Duration::from_millis(1000)); run_cmds(cmds, false, "update")?; @@ -1178,13 +1182,14 @@ fn get_before_uninstall() -> String { sc stop {app_name} sc delete {app_name} taskkill /F /IM {broker_exe} - taskkill /F /IM {app_name}.exe + taskkill /F /IM {app_name}.exe /FI \"PID ne {cur_pid}\" reg delete HKEY_CLASSES_ROOT\\.{ext} /f netsh advfirewall firewall delete rule name=\"{app_name} Service\" ", app_name = app_name, broker_exe = crate::ui::win_privacy::INJECTED_PROCESS_EXE, - ext = ext + ext = ext, + cur_pid = get_current_pid(), ) } @@ -1613,3 +1618,7 @@ pub fn is_foreground_window_elevated() -> ResultType { is_elevated(Some(process_id)) } } + +fn get_current_pid() -> u32 { + unsafe { GetCurrentProcessId() } +}