In tip 1891, we introduced Whoami.
RIGHTS.BAT uses Whoami to set the RGHT environment variable with the 23 user rights.
You can store the Username and %RGHT% in a network share, for subsequent production of a rights report, or you can test for a right and take an action based upon its' state.
Example - To test if the user has the right to change the system time:
"O" @echo Yes " %%i in ('whoami /priv') do call :parse %%i %%j
endlocal & set RGHT=%R01%%R02%%R03%%R04%%R05%%R06%%R07%%R08%%R09%%R10%%R11%%R12%%R13%%R14%%R15%%R16%%R17%%R18%%R19%%R20%%R21%%R22%%R23%&goto end
NOTE: We can see from the script that the right to change system time is R03.
The general form
of the expression is %RGHT:~(Rnn - 1),1%.
For /f "Tokens=1-2 Delims
The general form of the expression is %RGHT:~(Rnn - 1),1%.