Visual Studio Post Build Event MT.exe command fails with code 9009

試著忘記壹切 提交于 2019-12-03 11:04:59
jqa

Try adding quotes around the mt.exe path, e.g.:

"C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\mt.exe"

Also, make sure that path is valid.

Hope this helps. I've been beating my head against code 9009 all day and a full quoted path seem to make it work.

Nathan Wheeler

Exit code 9009 is a file not found error. The spaces that exist in your path to the post build command cause errors in a command prompt unless you include quotes around the entire path and executable name. Essentially, in your post-build command, it is trying to execute C:\Program with the arguments:

  • Files\Microsoft
  • SDKs\Windows\v7.0A\bin\mt.exe
  • -manifest "$(ProjectDir)$(TargetName).exe.manifest"
  • -updateresource:"$(TargetDir)$(TargetName).exe;#1"

Since obviously you don't have a file called Program residing in your root directory, this entire command fails. Encapsulating the path and executable in quotes will cause the entire expression to be evaluated as a single command, so everything should work fine if you change the post-build command to:

"C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\mt.exe" -manifest "$(ProjectDir)$(TargetName).exe.manifest" -updateresource:"$(TargetDir)$(TargetName).exe;#1"

Or use for VisualStudio x86 in Windows x64

"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin\mt.exe"
Shiraz Bhaiji

Here is a potential solution:

You can use the Post build event functionality of Visual Studio to do this typing the command above: mt.exe -manifest app.manifest -outputresource:myapplication.exe;#1. This probably won't work and Visual Studio will give you an error like "...exited with code 9009...".

You have to edit the csproj file using for example the notepad and uncomment the XML tags related to the Target Name="AfterBuild" (you can find them at the end of the file usually). Then, place the tags related to the PostBuildEvent within the tags related to the AfterBuild and then, reload the project and compile. It will produce a .exe file that needes to be execute with Administrator permissions.

bvj

Until reading this thread, I foolishly assumed VS would know where mt.exe lives. +1 to @james

Since there's no built-in macro for the current SDK, I relied on the system envar, windowssdkdir

 "%windowssdkdir%\bin\mt.exe"
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!