Add (Administrator) to the title bar if running with administrative privileges like Visual Studio
It is helpful for me to see at a glance if the process I am using is elevated or not - as by default they are not. Here is some sample code I tested in LINQPad to test it under my Win7 environment:
// using System.Security.Principal
WindowsIdentity user = WindowsIdentity.GetCurrent();
WindowsPrincipal principal = new WindowsPrincipal(user);
principal.IsInRole(WindowsBuiltInRole.Administrator).Dump();
Discussion point: I don't know if any automation tools look for a title bar named LINQPad 4 - but changing it could introduce a breaking change for those folks. I imagine that changed from older versions (though I can't remember honestly). Maybe have it exposed as an advanced preference that can be toggled?
-
Piers Williams commented
-
Goyuix commented
This code also seems to work properly, if you don't mind using P/Invoke
[DllImport("shell32.dll")] public static extern bool IsUserAnAdmin();
void Main()
{
IsUserAnAdmin().Dump();
}Thanks StackOverflow: http://stackoverflow.com/questions/1089046/in-net-c-test-if-user-is-an-administrative-user