private bool IsCurrentlyRunningAsAdmin(){bool isAdmin = false;WindowsIdentity currentIdentity = WindowsIdentity.GetCurrent();if (currentIdentity != null){WindowsPrincipal pricipal = new WindowsPrincipal(currentIdentity);isAdmin = pricipal.IsInRole(WindowsBuiltInRole.Administrator);pricipal = null;}return isAdmin;}