pub fn headless_command() -> Result<TokenCommand, ElevateError>Expand description
Create a TokenCommand configured strictly for headless Session 0 execution.
Has no desktop binding, making it mathematically impossible to trigger desktop DACL collisions.
Examples found in repository?
examples/headless_cmd.rs (line 13)
8fn main() -> Result<(), Box<dyn std::error::Error>> {
9 println!("Spawning headless background maintenance command...");
10
11 // `headless_command()` automatically binds to a Session 0 TrustedInstaller token
12 // with no desktop station attached, preventing any Session 0 DACL or access violations.
13 headless_command()?
14 .exe("%SystemRoot%\\System32\\cmd.exe")
15 .args("cmd.exe /k whoami /groups")
16 .spawn()?;
17
18 println!("Headless process spawned successfully in Session 0.");
19 Ok(())
20}