I have a windows app and i use the following to check if running as admin:
public static bool IsAdministrator()
{
var identity = WindowsIdentity.GetCurrent();
var principal = new WindowsPrincipal(identity);
return principal.IsInRole(WindowsBuiltInRole.Administrator);
}
if (!IsAdministrator())
{
AlrtBox.Show("Run as Admin");
}
But if i set a shortcut to the .exe file and set untick the checkbox Run As Administrator, it still seems to run regardless if checked or unchecked. I guess i am checking if the user is admin on windows(which they are) , but not if the check box is checked.
I want to check if the app is run as admin , regardless of the user on windows. How can i do that ?