self-runas

Crates.ioself-runas
lib.rsself-runas
version0.1.0
created_at2025-08-18 16:30:55.157975+00
updated_at2025-08-18 16:30:55.157975+00
descriptionrun this application with sudo/as admin
homepage
repositoryhttps://github.com/rustonbsd/self_runas
max_upload_size
id1800756
size27,996
fun with rust y2 (rustonbsd)

documentation

README

self_runas

Cross‑platform lib to elevate current process privilege to administrator/root.

Usage

fn main() -> anyhow::Result<()> {
    
    if !self_runas::is_elevated() {
        // relaunch elevated
        self_runas::admin()?;         
        return Ok(());
    }

    // privileged work here
    Ok(())
}

Install

  • Cargo.toml: [dependencies] self_runas = "0.1"

Notes

  • Propagates current args to elevated process.
  • Windows shows UAC by default; hides on non‑Windows.
  • Returns Err on failure to elevate.

License MIT OR Apache-2.0

Commit count: 0

cargo fmt