Merge pull request #1018 from fufesou/fix_cmd_window

fix_cmd_window: do not show cmd prompt window
This commit is contained in:
RustDesk 2022-07-21 22:17:51 +08:00 committed by GitHub
commit 515d90644a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View File

@ -343,8 +343,10 @@ fn get_capturer(use_yuv: bool) -> ResultType<CapturerInfo> {
#[cfg(windows)]
let mut captuerer_privacy_mode_id = privacy_mode_id;
#[cfg(windows)]
if crate::ui::win_privacy::is_process_consent_running()? {
captuerer_privacy_mode_id = 0;
if captuerer_privacy_mode_id != 0 {
if crate::ui::win_privacy::is_process_consent_running()? {
captuerer_privacy_mode_id = 0;
}
}
log::debug!(
"Try create capturer with captuerer privacy mode id {}",

View File

@ -5,6 +5,7 @@ use crate::{
use hbb_common::{allow_err, bail, lazy_static, log, tokio, ResultType};
use std::{
ffi::CString,
os::windows::process::CommandExt,
sync::Mutex,
time::{Duration, Instant},
};
@ -24,7 +25,9 @@ use winapi::{
CreateProcessAsUserW, GetCurrentThreadId, QueueUserAPC, ResumeThread,
PROCESS_INFORMATION, STARTUPINFOW,
},
winbase::{WTSGetActiveConsoleSessionId, CREATE_SUSPENDED, DETACHED_PROCESS},
winbase::{
WTSGetActiveConsoleSessionId, CREATE_NO_WINDOW, CREATE_SUSPENDED, DETACHED_PROCESS,
},
winnt::{MEM_COMMIT, PAGE_READWRITE},
winuser::*,
},
@ -317,6 +320,7 @@ fn wait_find_privacy_hwnd(msecs: u128) -> ResultType<HWND> {
pub fn is_process_consent_running() -> ResultType<bool> {
let output = std::process::Command::new("cmd")
.args(&["/C", "tasklist | findstr consent.exe"])
.creation_flags(CREATE_NO_WINDOW)
.output()?;
Ok(output.status.success() && !output.stdout.is_empty())
}