static bool IsElevated()
{
WindowsIdentity currentIdentity = WindowsIdentity.GetCurrent();
if(currentIdentity != null)
{
WindowsPrincipal principal = new WindowsPrincipal(currentIdentity);
return principal.IsInRole(WindowsBuiltInRole.Administrator);
}
return false;
}