You will need to add a custom manifest to your project and then include it into the project's properties. The manifest is a simple xml file in the following format:
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestversion="1.0">
<assemblyidentity version="1.0.0.0" name="MyApplication.app" />
<trustinfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedprivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedexecutionlevel level="requireAdministrator" uiaccess="false" />
</requestedprivileges>
</security>
</trustinfo>
</assembly>
You can find the default manifest file for your project in the
bin\Debug and
bin\Release directories, so you can use one of those as the basis for your custom file. The key change is in the
node, where the
requestedExecutionLevel level
must be set equal to
requireAdministrator
as shown in the sample above.