更改目录并在同一命令提示符下运行批处理文件 [英] change directory and run the batch file in the same command prompt

查看:163
本文介绍了更改目录并在同一命令提示符下运行批处理文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在命令提示符下打开命令提示符并更改目录,并使用java在同一命令提示符下运行批处理文件。

Is there any way to open the command prompt and change directory in the command prompt and run the batch file in the same command prompt using java.

我知道如何使用java打开命令提示符。
谢谢,

I know how to open the command prompt using java. Thanks,

推荐答案

您可以使用cmd.exe / K的值对CD和批处理文件进行编码。来自doco(cmd /?):

You can encode the CD and the batch file in the value for cmd.exe /K. From the doco (cmd /?):


请注意,命令分隔符'&&'
分隔的多个命令如果被引号包围,则接受字符串。

Note that multiple commands separated by the command separator '&&' are accepted for string if surrounded by quotes.

例如:

cmd /C "CD C:\ && Dir"
cmd /C "CD C:\Windows && Dir"
cmd /C "CD C:\Windows && MySuperSuperBatchFile"

有关详细信息,请运行:

For more detail, run:

cmd /?

这篇关于更改目录并在同一命令提示符下运行批处理文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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