[−][src]Crate runas
This library implements basic support for running a command in an elevated context.
In particular this runs a command through "sudo" or other platform equivalents.
Basic Usage
The library provides a single struct called Command
which largely follows the
API of std::process::Command
. However it does not support capturing output or
gives any guarantees for the working directory or environment. This is because
the platform APIs do not have support for that either in some cases.
In particular the working directory is always the system32 folder on windows and the environment variables are always the ones of the initial system session on OS X if the GUI mode is used.
use runas::Command; let status = Command::new("rm") .arg("/usr/local/my-app") .status() .unwrap();
Platform Support
The following platforms are supported:
- Windows: always GUI mode
- OS X: GUI and CLI mode
- Linux: CLI mode
Structs
Command | A process builder for elevated execution, providing fine-grained control over how a new process should be spawned. |