sudo icon indicating copy to clipboard operation
sudo copied to clipboard

`is-elevated` command

Open zdm opened this issue 10 months ago • 0 comments

Description of the new feature / enhancement

Could you please add new is-elevated command. It should check for elevated permissions and return 0 if process is already elevated.

sudo is-elevated && echo Already elevated

Scenario when this would be used?

This is useful feature and can be used in many scenarios.

For example if will allow to create self-elevated scripts:

test.cmd:

:: check for elevated permissions
:: - if already elevated - continue run
:: - if NOT elevated - elevate myself, run and exit
sudo is-elevated || ( sudo -E "%~sf0" %* & exit /B )

echo Run elevated code here

Supporting information

No response

zdm avatar Feb 01 '25 17:02 zdm