Test for Windows Administrator permissions from Cygwin terminal|script?
Backwoods BC
completely.and.totally.trash@gmail.com
Fri Aug 18 02:18:11 GMT 2023
On Thu, Aug 17, 2023 at 7:01 PM Martin Wege via Cygwin
<cygwin@cygwin.com> wrote:
> How can I find out whether the current Cygwin terminal has
> Administrator rights? I want to safeguard our admin scripts with a
> simple test and bail out with an error if someone wants to do admin
> stuff (say: regtool) without admin privileges.
>
> Thanks,
> Martin
I don't know if this is the official method, but it works for me:
##### Shell Options
# Elevated privilege windows have $SESSIONNAME set
if [ "$SESSIONNAME" == "" ] ;then
printf -v adminPmt '[\u2022Admin\u2022] '
else
export adminPmt=""
fi
More information about the Cygwin
mailing list