如何依次执行几个批处理命令 [英] How to execute several batch commands in sequence

查看:259
本文介绍了如何依次执行几个批处理命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个Windows XP批处理脚本,该脚本顺序执行以下操作:

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.

推荐答案

我认为您的问题是,当您调用mvn命令时,您再也不会返回到脚本了.

I think your problem is that when you invoke mvn command you never go back to your script again.

尝试使用 call 命令,例如:

Try using the call command e.g.:

call mvn clean install

这将调用mvn clean install命令,然后返回到脚本.

This will invoke mvn clean install command and then return back to your script.

当您简单地调用mvn而没有call时,实际上是调用

When you simply invoke mvn without call you actually invoke mvn.bat file and pass control to it.

这篇关于如何依次执行几个批处理命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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