portable-service: run background
Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
parent
3f77b6bc64
commit
45bfb0e22e
@ -1480,6 +1480,27 @@ pub fn get_user_token(session_id: u32, as_user: bool) -> HANDLE {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn run_background(exe: &str, arg: &str) -> ResultType<bool> {
|
||||||
|
let wexe = wide_string(exe);
|
||||||
|
let warg;
|
||||||
|
unsafe {
|
||||||
|
let ret = ShellExecuteW(
|
||||||
|
NULL as _,
|
||||||
|
NULL as _,
|
||||||
|
wexe.as_ptr() as _,
|
||||||
|
if arg.is_empty() {
|
||||||
|
NULL as _
|
||||||
|
} else {
|
||||||
|
warg = wide_string(arg);
|
||||||
|
warg.as_ptr() as _
|
||||||
|
},
|
||||||
|
NULL as _,
|
||||||
|
SW_HIDE,
|
||||||
|
);
|
||||||
|
return Ok(ret as i32 > 32);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn run_uac(exe: &str, arg: &str) -> ResultType<bool> {
|
pub fn run_uac(exe: &str, arg: &str) -> ResultType<bool> {
|
||||||
let wop = wide_string("runas");
|
let wop = wide_string("runas");
|
||||||
let wexe = wide_string(exe);
|
let wexe = wide_string(exe);
|
||||||
|
@ -476,7 +476,12 @@ pub mod client {
|
|||||||
unsafe {
|
unsafe {
|
||||||
libc::memset(shmem.as_ptr() as _, 0, shmem.len() as _);
|
libc::memset(shmem.as_ptr() as _, 0, shmem.len() as _);
|
||||||
}
|
}
|
||||||
if crate::common::run_me(vec!["--portable-service"]).is_err() {
|
if crate::platform::run_background(
|
||||||
|
&std::env::current_exe()?.to_string_lossy().to_string(),
|
||||||
|
"--portable-service",
|
||||||
|
)
|
||||||
|
.is_err()
|
||||||
|
{
|
||||||
*SHMEM.lock().unwrap() = None;
|
*SHMEM.lock().unwrap() = None;
|
||||||
bail!("Failed to run portable service process");
|
bail!("Failed to run portable service process");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user