On Thu, Aug 17, 2023 at 8:02 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.

I use this bash function:

# isadmin - is shell a regular user or admin user
function isadmin()
{
    $(cygpath -u 'C:\Windows\System32\net.exe') session > /dev/null 2>&1
    if [ $? -eq 0 ]; then echo "admin"
    else echo "user"; fi
}

I imagine any other Windows app that needs admin permissions would work.

I use this to change the color of the prompt ($PS1) for the admin user to red.

HTH
Doug

-- 
Doug Henderson, Calgary, Alberta, Canada - from gmail.com

-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

Reply via email to