Zayko in the Net

Personal blog of Vitaly Zayko

NAVIGATION - SEARCH

How to check is your App running under Admin privileges (C#)?

You have to know this before your App does something that requires Administrator privileges. Actually it is quite easy:

using System.Security.Principal; public bool IsAdmin() { WindowsPrincipal principal = new WindowsPrincipal(WindowsIdentity.GetCurrent()); return principal.IsInRole(WindowsBuiltInRole.Administrator); }

Add comment