The following manifest XML tells the .NET Framework to run the Assembly that you specify as Administrator within Windows Vista:
<?xml version="1.0" encoding="utf-8" ?> <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> <assemblyIdentity version="22.214.171.124" processorArchitecture="X86" name="MyAppExeName" type="win32" /> <description>This is description of created application</description> <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"> <security> <requestedPrivileges> <requestedExecutionLevel level="requireAdministrator" /> </requestedPrivileges> </security> </trustInfo> </assembly>
Now, there are two ways to make your program use this Manifest:
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 on visual studio command line (Command Prompt):
mt -manifest YourProgram.exe.manifest -outputresource:YourProgram.exe
If your assembly is strong named, you will be unable to embed the manifest into it as it would invalidate the strong naming.
Now your own C# application will prompt to run as Administrator in Windows Vista or Window 7.
in Visual studio 2010 you can also add manifest by adding by right click on project and select add new item and select manifest file from the list and modify this file as above xml.