Check your application’s running location and user rights
//Get the running drive of this application
Console.WriteLine(Directory.GetDirectoryRoot(Assembly.GetExecutingAssembly().Location));
String sddlAdmins = "S-1-5-32-544"; //Sid of administrators group
IdentityReference AdminsSid = new SecurityIdentifier(sddlAdmins);
if (WindowsIdentity.GetCurrent().Groups.Contains(AdminsSid))
Console.WriteLine("Running with admin rights!");
Console.WriteLine(Directory.GetDirectoryRoot(Assembly.GetExecutingAssembly().Location));
String sddlAdmins = "S-1-5-32-544"; //Sid of administrators group
IdentityReference AdminsSid = new SecurityIdentifier(sddlAdmins);
if (WindowsIdentity.GetCurrent().Groups.Contains(AdminsSid))
Console.WriteLine("Running with admin rights!");
Comments
Post a Comment