run_as_user use vec arg

Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
21pages
2022-11-27 12:31:53 +08:00
parent 99f41007e9
commit 51cfa6f666
4 changed files with 17 additions and 18 deletions

View File

@@ -580,11 +580,11 @@ async fn launch_server(session_id: DWORD, close_first: bool) -> ResultType<HANDL
Ok(h)
}
pub fn run_as_user(arg: &str) -> ResultType<Option<std::process::Child>> {
pub fn run_as_user(arg: Vec<&str>) -> ResultType<Option<std::process::Child>> {
let cmd = format!(
"\"{}\" {}",
std::env::current_exe()?.to_str().unwrap_or(""),
arg,
arg.join(" "),
);
let session_id = unsafe { get_current_session(share_rdp()) };
use std::os::windows::ffi::OsStrExt;
@@ -596,7 +596,7 @@ pub fn run_as_user(arg: &str) -> ResultType<Option<std::process::Child>> {
let h = unsafe { LaunchProcessWin(wstr, session_id, TRUE) };
if h.is_null() {
bail!(
"Failed to launch {} with session id {}: {}",
"Failed to launch {:?} with session id {}: {}",
arg,
session_id,
get_error()