Expand description
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 run_as::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: GUI and CLI mode
Structs§
- Command
- A process builder for elevated execution
Functions§
- is_
elevated - Check if the current process is running with elevated privileges.
- restart_
self - Re-execute the current program with configurable wait behavior
- restart_
self_ elevated - Re-execute the current program with elevated privileges