Skip to main content

headless_cmd/
headless_cmd.rs

1//! Example demonstrating headless `TrustedInstaller` execution.
2//!
3//! Ideal for background services, automated maintenance, CI/CD pipelines,
4//! and environments without an active GUI/desktop session (Session 0).
5
6use elevate_ti::headless_command;
7
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}