using System.Security.Principal;
public static Boolean HasAdminRights()
{
try
{
var user = WindowsIdentity.GetCurrent();
var principal = new WindowsPrincipal(user);
return principal.IsInRole(WindowsBuiltInRole.Administrator);
}
catch
{
return false;
}
}
Wednesday, December 17, 2014
[C#] How to detect if application is running with local administrator rights
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment