I wanted to detect if my program is started via "Run as Administrator" or not. On two machines it works by doing:
new System.Security.Principal.WindowsPrincipal(System.Security.Principal.WindowsIdentity.GetCurrent()).IsInRole(System.Security.Principal.WindowsBuiltInRole.Administrator)
Because when I run programs, by default they don't run as Administrator, so I can check it like that.
However on yet another machine (this one has Win7 and UAC disabled) and when I start any program there it automatically starts with admin rights, without ever having to "Right click -> Run as Administrator". Can I somehow filter this instance out?
Background is simply, that on the very first start it should prevent the user from starting it elevated, but if the user starts it elevated every time anyways it shouldn't care.
Hope it makes sense, Matty