How can I tell if my script is being run in elevated mode?

1

This is mainly to change the prompt for elevated shells in Cygwin.

I need to know a fast command of either Windows or Cygwin that tells me whether i'm elevated in Windows 7.

LatinSuD

Posted 2014-09-10T15:57:57.313

Reputation: 1 194

Answers

1

As stated here it's done with the help of Cygwin's command id:

id -G | egrep -q '\<544\>' && set prompt = '#  || set prompt = '\$ ' 

Or in my case with bash i added this to the end of /etc/bash.bashrc (Note that I removed the \n that comes in default prompt):

id -G | egrep -q '\<544\>' &&
 PS1='\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]# ' ||
 PS1='\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\$ '

LatinSuD

Posted 2014-09-10T15:57:57.313

Reputation: 1 194