Skip to content

admin

Query administrator privileges and elevate to them in a cross-platform manner.


Functions

query()

Reports whether the active target has effective administrator privileges.

On Windows, this checks whether the access token is elevated. On Unix, it checks whether the effective user ID is zero.

Returns

Bool

with block :cd? :env?

Runs block with administrator privileges.

Windows uses UAC and Unix uses sudo. If the current context already has administrator privileges, block runs directly.

Filesystem access and spawned programs use the elevated VFS for the duration of the block.

Parameters
Name type Description
block callable Block to run
Returns

The result of block.

Example
admin.with do
  echo "administrator: $(admin.query())"