#windows #sudo #uac #elevate #administrator

windows-elevate

windows-elevate is a Windows-only library which provides utility functions to help elevating process permissions

1 unstable release

0.1.0 Sep 2, 2024

#3 in #elevate

Download history 114/week @ 2024-08-28 29/week @ 2024-09-04

143 downloads per month

MIT license

10KB
138 lines

windows-elevate

windows-elevate is a Windows-only crate, it provides two utility functions:

  • check_elevated() is used to determine whether the current process is running as elevated.
  • elevate() is used to elevate the current process permissions.

Example

use windows_elevate::{check_elevated, elevate};

fn test_elevate() {
   let is_elevated = check_elevated().expect("Failed to call check_elevated");

   if !is_elevated {
       elevate().expect("Failed to elevate");
       return;
   }
   // From here, it's the new elevated process
}

lib.rs:

windows-elevate is a Windows-only crate, it provides utility two functions:

  • check_elevated() is used to determine whether the current process is running as elevated.
  • elevate() is used to elevate the current process permissions.

Example

use windows_elevate::{check_elevated, elevate};

fn test_elevate() {
   let is_elevated = check_elevated().expect("Failed to call check_elevated");

   if !is_elevated {
       elevate().expect("Failed to elevate");
       return;
   }
   // From here, it's the new elevated process
}

Dependencies

~127MB
~2M SLoC