This is probably something that is pretty common knowledge but I have been asked this a few times. So because I need to write about something here it is…
Using Visual Studio Build Solution:
1. Open Visual Studio (I am using VS 2010)
2. Right your project
3. Highlight Add
4. Select New Item
5.Select Application Manifest File
6. Change the name to match the name of the exe.
- Example someProgram.exe.manifest
7. Click ‘Add’
8. Open the manifest file and look for the line requestedExecutionLevel
- Default line will probably look like this:
<requestedExecutionLevel level=”asInvoker” uiAccess=”false” />
9.Replace this line with:
<requestedExecutionLevel level=”requireAdministrator” uiAccess=”false” />
10. Save the changes
11. Open the project properties
12. Under Application locate the Manifest drop down
13. Your manifest may already be selected. if not click the arrow and select.
14. Save your changes
15. Rebuild your solution.
Your application should now launch the Yellow UAC box requesting admin privileges. If you want to get rid of the yellow box you will need to code sign the exe.
Using Windows SDK MT.exe:
By default if the Windows SDK is installed (if not install it) the MT.exe is located in C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin
1. First thing you need to do is create the manifest file. It is a simple XML file that looks like this:
<?xml version=”1.0″ encoding=”UTF-8″ standalone=”yes”?>
<assembly xmlns=”urn:schemas-microsoft-com:asm.v1″ manifestVersion=”1.0″>
<assemblyIdentity version=”1.0.0.0″ name=”someProgram.EXE” type=”win32″/>
<trustInfo xmlns=”urn:schemas-microsoft-com:asm.v3″>
<security>
<requestedPrivileges>
<requestedExecutionLevel level=”requireAdministrator”/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
2. Set the name to be the name of the exe file, in this example it is someProgram.exe
3. Verify that you have the tag:
<requestedExecutionLevel level=”requireAdministrator”/>
4. Save your changes
5. Bring up cmd.exe as Administrator
6. run the following command (this is one line, to make it easier to read I broke it down to two lines):
7. It should return that it was successful and you should not have an exe that will launch using the UAC.
Few things to note about this process:
- mt.exe can be copied out of the sdk and moved to a different folder
- I have successfully written a PowerShell script that will look for all exe files, check a different folder that stores the manifest files. If it exist it runs this command.
Thank you dude, it’s very helpful.
This was what I was looking for, but it doesnt seem to work now.
We get an msvcr90.dll not found. Even putting the dll files and installing vcredistributable does not solve the problem (This makes the dll not found go away but the program still fails to execute)