To have your C# (or any .NET program) run as Administrator in Windows, you'll have to create a manifest for it.
Step 1: Add a manifest file to your app.
Solution Explorer>Rightclick>Add>"New Item">"Application Manifest File"
Step 1: Add a manifest file to your app.
Solution Explorer>Rightclick>Add>"New Item">"Application Manifest File"
Step2 : Manipulate the default manifest file as follows
Just change the highlighted attribute from a"asInvoked" to "requireAdministrator"
Step 3: Make your app to use the manifest
[If Not using Visual Studio]
1. Rename it to (YourEXEName).manifest. The .NET Framework when executing the file will see the Manifest and handle its contents.
2.Embed the .manifest file into you EXE. This can be done by executing the following command line:
1.mt -manifest YourProgram.exe.manifest -outputresource:YourProgram.exe
2.If your assembly is strong named, you will be unable to embed the manifest into it as it would invalidate the strong naming.
[If using Visual Studio]
1. Dont have to do anything more...
2. Just remember to run the Visual Studio as an Administrator, for future debugging.