withPrivileges method

void withPrivileges(
  1. RunPrivileged action, {
  2. bool allowUnprivileged = false,
})

Run action throwing if the process isn't running as a Windows Administrator

Implementation

void withPrivileges(RunPrivileged action, {bool allowUnprivileged = false}) {
  if (!allowUnprivileged && !Shell.current.isPrivilegedUser) {
    throw ShellException(
      'You can only use withPrivileges when running as a privileged user.',
    );
  }
  action();
}