I have a C# Program that is supposed to be multi-OS compatible. It requires access to create a directory and get WMI Data, but that is only available if the program is ran as an Administrator. Otherwise, it fails.
Is there any command I can use to not run the program if it does not detect itself as being ran as an administrator? I tried adding a app.manifest and using “requireAdministrator”, it prompts for login, but that appears to only work on Windows 7 and Vista, not XP.
Example:
if (isAdmin==0)
Console.WriteLine("Please run this as an administrator");
exit;
Check if the User Is an Admin
Restart the app if not an admin
Application Manifest File (Used to automatically Run as Admin)