Created
January 25, 2018 09:01
-
-
Save idiotandrobot/0238019079641b0ac5f735e66edb5c8b to your computer and use it in GitHub Desktop.
Mark .NET application to run as Administrator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static bool HasAdministratorPrivileges() | |
{ | |
WindowsIdentity id = WindowsIdentity.GetCurrent(); | |
WindowsPrincipal principal = new WindowsPrincipal(id); | |
return principal.IsInRole(WindowsBuiltInRole.Administrator); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment