把多个命令连接成一个批处理文件 [英] Putting multiple commands into one batch file

查看:192
本文介绍了把多个命令连接成一个批处理文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我喜欢这种感觉有这么简单,不管怎样我只是失去了一些东西。我有3个命令我必须连续执行背靠背。我怎样才能把这些都在一个批处理文件?

I feel like this has to be so simple and somehow I'm just missing something. I have 3 commands that I have to continuously execute back to back. How can I put those all into one batch file?

下面是命令:

cl /c /Zl /I"c:\EFI_Toolkit_2.0\include\efi" /I"c:\EFI_Toolkit_2.0\include\efi\em64t" c:\sandbox\efi_main.c
link /entry:main /dll /IGNORE:4086 efi_main.obj
fwimage.exe app efi_main.dll efi_main.efi

我已经尝试添加启动每行的盈方,而我看到回显的每个命令只有第一个被执行(即我只得到efi_main.obj而不是.dll或.efi)。

I've tried adding 'start' infront of each line, and while I see each command echo'd only the first one is executing (i.e I only get efi_main.obj but not .dll or .efi).

此外,这些需要在格兰Visual Studio的外壳要执行,只要我从shell中运行我的批处理文件,我想这就是sufficent?

Also these need to be executed in teh visual studio shell, as long as I run my batch file from within the shell I assume thats sufficent?

推荐答案

如果你的意思是他们执行一前一后,重复,尝试这样的事情:

If you mean them to execute one after the other, and repeat, try something like this:

:begin
cl /c /Zl /I"c:\EFI_Toolkit_2.0\include\efi" /I"c:\EFI_Toolkit_2.0\include\efi\em64t" c:\sandbox\efi_main.c
link /entry:main /dll /IGNORE:4086 efi_main.obj
fwimage.exe app efi_main.dll efi_main.efi
goto begin

如果你的意思是他们同时运行,preFIX与每个命令启动

if you mean for them to run simultaneously, prefix each command with start.

start cl /c /Zl /I"c:\EFI_Toolkit_2.0\include\efi" /I"c:\EFI_Toolkit_2.0\include\efi\em64t" c:\sandbox\efi_main.c
start link /entry:main /dll /IGNORE:4086 efi_main.obj
start fwimage.exe app efi_main.dll efi_main.efi

但它看起来像你想运行一个编译器。所以有机会,你需要将两种方法结合起来,等待第一个移动到下一个命令,或再次重复之前完成运行。对于这一点,你应该在/等待参数添加到启动命令。

:begin
start /wait cl /c /Zl /I"c:\EFI_Toolkit_2.0\include\efi" /I"c:\EFI_Toolkit_2.0\include\efi\em64t" c:\sandbox\efi_main.c
start /wait link /entry:main /dll /IGNORE:4086 efi_main.obj
start /wait fwimage.exe app efi_main.dll efi_main.efi
goto begin

请注意,如果你从Visual Studio内运行,你可以使用所有酷的Visual Studio环境选项抢东西,如项目文件夹,项目输出等,但也没办法,开始像一个批处理文件这从VS壳牌连续运行,并返回焦点VS.此外,该文件将永远不会结束运行,直到你给它的重点和preSS Ctrl-C来结束它。

Note that if you're running this from within visual studio, you can use all the cool Visual Studio environment options to grab things like the project folder, project output, etc. But there is no way to start a batch file like this to run continuously from the VS Shell and return focus to VS. Also, this file will never finish running until you give it focus and press Ctrl-C to end it.

这篇关于把多个命令连接成一个批处理文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆