2009-09-14 72 views
24

我试图使用mt.exe从Windows SDK的清单添加到没有一个可执行文件,使用以下命令行:如何使用mt.exe将清单添加到可执行文件?

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

不幸的是,当我这样做,我得到这个错误:

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. 

当然,资源没有在文件中找到 - 该文件没有清单,这就是为什么我想添加一个。

如何将清单附加到可执行文件?这不应该简单吗?

回答

22

您应该使用/outputresource而不是/更新资源:

正确的命令行是:

mt.exe -nologo -manifest "r:\shared\hl.exe.manifest" -outputresource:"r:\shared\hl33m.exe;#1" 
4

您也可以使用这样的嵌入EXE文件中的清单:

mt.exe -nologo -manifest“R:\共享\ hl.exe.manifest” -outputresource: “R:\共享\ hl33m.exe 1”

7

这为我工作的VS 2005:

  1. 创建以带有扩展名清单的可执行文件命名的文本文件,并确保它位于与代码文件相同的路径中;即Form1.cs等。例如,如果您的应用程序名称为UACTester.exe,那么您的清单文件应该命名为UACTester.exe.manifest。
  2. 确保清单内容良好。我用这一个:
<?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. 在您的可执行项目,添加以下生成后事件:

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

希望这有助于。祝你好运! -Matt Esterak

相关问题