为多个CMD制作批处理文件 [英] Making a batch file for multiple CMDs

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

问题描述

让我们说我有两个要启动的服务和一个属性文件.

Lets say I have 2 services I want to start and a property file.

 -svc1.cmd
 -svc2.bat
 -svc2prop.properties

我们将目录设置为C:\ program1 \ bin \和C:\ program2 \ bin \ + C:\ program2 \ config \

Lets have directories as C:\program1\bin\ and C:\program2\bin\ + C:\program2\config\

然后我尝试这样做:

start cmd /k call C:\program1\bin\svc1.cmd
start cmd /k cd C:\program2\ .\bin\svc2.bat .\config\svc2prop.properties

我可以通过打开本地CMD来分别启动它们.问题是,如果我在目录C:\ program2 \中,则可以打开本地CMD并运行此语句,而不会出现问题.\ bin \ svc2.bat.\ config \ svc2prop.properties"

I can start them both separately by opening a local CMD. The thing is, if I am in the directory C:\program2\ I can open up a local CMD and run this statement without problems " .\bin\svc2.bat .\config\svc2prop.properties"

但是我想创建一个批处理文件:首先,打开一个新的cmd并启动svc1.cmd,然后打开另一个cmd,该文件进入C:\ program2 \并运行".\ bin \ svc2 .bat.\ config \ svc2prop.properties"语句...但由于某种原因,它不起作用.

But I want to create a batch file that: first, opens a new cmd and starts the svc1.cmd, then opens another cmd in which it goes to C:\program2\ and runs the "" .\bin\svc2.bat .\config\svc2prop.properties" " statement ... but for some reason it doesnt work.

任何可能的解决方案吗?

Any possible solution ?

推荐答案

第二行应使用/D选项在所需目录中启动该过程:

the second line should use /D option to start the process in the required directory:

start /D C:\program2 cmd /k .\bin\svc2.bat .\config\svc2prop.properties

(在您的示例中,您只是向无用的cd命令传递了很多参数)

(in your example, you were just passing a lot of arguments to an useless cd command)

如果第一行当前存在一些目录问题,请执行相同操作:

If you have some current directory problems with the first line, just do the same:

start /D C:\program1\bin cmd /k call svc1.cmd

这篇关于为多个CMD制作批处理文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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