Many time we have requirement to run application only as a administrator account. not application we need to secure single windows form at many time to give access to those user who have not Admin account privilege.
Take a look how to accomplish this task using C# language in your program.
To accomplish it you can use simple function name is isAdm() which is described below
to access class like WindowsIdentity you need to use System.Security.Principal namespace in your code file.
and then create function name isAdm()
isAdm() function having boolean return type which will return true if apllication is running in Admin account else it will return false.
and then write given code
public static bool isAdm()
WindowsIdentity identity = WindowsIdentity.GetCurrent();
WindowsPrincipal principal = new WindowsPrincipal(identity);
How to use this Function in your program
you can simply use this function in your program at specifying isAdm function in your entry point. for this you need to open Program.Cs file where entry points resides.
After using isAdm function your code will be as given below
static void Main()
MessageBox.Show("You must run this application as Administrator");
Now its completed and you are ready to test your application that its running in Admin account or not.
when you compile your code or executing Application exe file you will notice it will run if its running as administrator account otherwise it will give you error which is mentioned while creating program in entry point.
for getting more details you should download code.