Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I add a manifest to an executable using mt.exe?

I'm trying to use mt.exe from the Windows SDK to add a manifest to an executable file that doesn't have one, using the following command line:

C:\winsdk61>mt.exe -nologo -manifest "r:\shared\hl.exe.manifest" -updateresource:"r:\shared\hl33m.exe;#1" 

Unfortunately, when I do, I get this error:

mt.exe : general error c101008c: Failed to read the manifest from the resource of file "r:\shared\hl33m.exe". The specified resource type cannot be found in the image file. 

Of course the resource wasn't found in the file - the file doesn't have a manifest, that's why I want to add one.

How can I append a manifest to an executable file? Shouldn't this be simple?

like image 802
Colen Avatar asked Sep 14 '09 19:09

Colen


People also ask

How do I add manifest?

Right click your project file on the Solution Explorer, select Add , then New item (or CTRL+SHIFT+A). There you can find Application Manifest File . The file name is app. manifest.

What does MT exe do?

The Mt.exe file is a tool that generates signed files and catalogs. It is available in the Microsoft Windows Software Development Kit (SDK). Mt.exe requires that the file referenced in the manifest be present in the same directory as the manifest.

What is exe manifest file?

A MANIFEST file is an XML document that describes the manifest, or package contents, of a Windows software application. It is used by various Windows technologies for configuring and deploying software, including ClickOnce and the Common Language Runtime (CLR). MANIFEST files are often seen with the compound ".exe.


2 Answers

You should use /outputresource instead of /updateresource:.

The correct command line would be:

mt.exe -nologo -manifest "r:\shared\hl.exe.manifest" -outputresource:"r:\shared\hl33m.exe;#1" 
like image 195
Cristian Adam Avatar answered Sep 22 '22 09:09

Cristian Adam


This worked for me for VS 2005:

  1. Create text file named after executable with extension manifest, and ensure it is located in the same path as your code files; i.e. Form1.cs, etc. For example, if your app name is UACTester.exe then your manifest file should be named UACTester.exe.manifest.
  2. Ensure the contents of the manifest is good. I use this one:
    <?xml version="1.0" encoding="utf-8"?>     <asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1"      xmlns:asmv1="urn:schemas-microsoft-com:asm.v1"       xmlns:asmv2="urn:schemas-microsoft-com:asm.v2"       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">         <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>                 <applicationRequestMinimum>                     <defaultAssemblyRequest permissionSetReference="Custom" />                     <PermissionSet class="System.Security.PermissionSet"                       version="1" ID="Custom" SameSite="site" />                 </applicationRequestMinimum>             </security>         </trustInfo>         <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">             <application>             </application>         </compatibility>     </asmv1:assembly> 
  1. On your executable project, add the following post-build event:

    "$(DevEnvDir)..\Tools\Bin\mt.exe" -nologo -manifest "$(TargetPath).manifest" -outputresource:"$(TargetPath)"

Hope this helps. Good luck! -Matt Esterak

like image 28
mesterak Avatar answered Sep 19 '22 09:09

mesterak