如何按顺序执行多个批处理命令
我想创建一个 Windows XP 批处理脚本,该脚本顺序执行如下所示的操作:
@echo off
:: build everything
cd \workspace\project1
mvn clean install
cd ..\project2
mvn clean install
:: run some java file
cd \workspace\project3
java -jar somefile.jar
当我创建这样的批处理脚本时(遵循
mvn clean install
“noreferrer">这些 指令),我仍然遇到脚本在第一个指令之后停止执行某些操作然后显示命令行 。 如何在一个批处理文件中按顺序执行所有这些命令?
我不想引用其他文件,我想要在一个文件中完成它。
I want to create a Windows XP batch script that sequentially performs something like the following:
@echo off
:: build everything
cd \workspace\project1
mvn clean install
cd ..\project2
mvn clean install
:: run some java file
cd \workspace\project3
java -jar somefile.jar
When I create a Batch script like this (following these instructions), I still have the problem that the script stops doing something after the first
mvn clean install
and then displays the command line.
How can i execute all of these commands in sequence in one batch file?
I don't want to refer to other files, I want to do it in one file.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为你的问题是,当你调用 mvn 命令时,你再也不会回到你的脚本了。
尝试使用
call
命令,例如:这将调用
mvn clean install
命令,然后返回到您的脚本。当您简单地调用
mvn
而没有call
时,您实际上调用了mvn.bat
文件并将控制权传递给它。I think your problem is that when you invoke
mvn
command you never go back to your script again.Try using the
call
command e.g.:This will invoke
mvn clean install
command and then return back to your script.When you simply invoke
mvn
withoutcall
you actually invokemvn.bat
file and pass control to it.您需要在
mvn
上使用call
命令(这似乎是另一个批处理文件?),如下所示:
来源:google 是您的朋友。
You'll need to use the
call
command onmvn
(which seems to be another batch file?)Like this:
Source: google is your friend.