How to run multiple batch files with single External Tool in Visual Studio

心已入冬 提交于 2019-12-24 12:53:55

问题


In Visual Studio, using External Tools, is it possible to have a tool set up to execute multiple .bat files?

I have two .bat files in my project directory and I currently have a tool for each of them set up, so I go up to Tools and select each one. I was trying to find a way to run both .bat files at once without creating a third .bat file just to call those .bat files.

Each one individual has the Command pointed to the cmd.exe, and their Arguments as /C filename.bat

Is there a way to pass in both of the .bat files to have them run sequentially (or in parallel, I'm not picky) or will I need to create a third .bat file to point to each of them?


回答1:


Use the & chaining commands operator; or better yet the && conditional chaining operator that only invokes the second command when the first one has successfully run (exit code is 0).

Try it first in the command line

 start cmd /c "so1 && so2"

if you have problems with competing quotes (the case when the commands themselves need to use quotes), you can also escape with ^ the & character

 start cmd /c so1 ^& so2

finally set your new external tool arguments to the syntax that better fits your requirements, probably /c "so1 && so2" will be enough.



来源:https://stackoverflow.com/questions/35208311/how-to-run-multiple-batch-files-with-single-external-tool-in-visual-studio

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