从单一的批处理文件,启动多个shell提示符 [英] Launching multiple shell prompts from a single batch file

查看:177
本文介绍了从单一的批处理文件,启动多个shell提示符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一组DOS命令,我需要在不同的shell实例上运行。是否有一个批处理文件,我可以写,将设置多个CMD实例和DOS中的每个提示?命令执行set

I have a set of DOS commands that I need to run in different shell instances. Is there a single batch file I can write that would set of multiple cmd instances and execute the set of DOS commands in each of the prompts?

推荐答案

您的问题似乎到如何运行一个不同的系列中的cmd.exe的每个实例的命令沸腾,而无需多个命令文件。

Your question seems to boil down to how to run a different series of commands in each instance of cmd.exe without having multiple command files.

有这样做的相当简单的方式。我们的想法是运行CMD.EXE的每个实例相同的命令文件,但通过它,告诉它做其工作的一部分命令行参数。

There's a reasonably straightforward way of doing this. The idea is to run the same command file in each instance of cmd.exe, but pass it a command-line parameter that tells it which part of the job to do.

这里的一个有用的技巧是使用命令行参数的命令后藤,像这样的:

A useful trick here is to use the command-line parameter in a goto command, like this:

if not "%1" == "" goto :%1

start "Job 1" "%~dpfx0" job1
start "Job 2" "%~dpfx0" job2
goto :eof

:job1

echo Job 1
pause
exit

:job2

echo Job 2
pause
exit

还要注意运用%〜dpfx0来确定当前脚本的完整路径和名称。这有可能成为行情的情况下,路径中包含空格,这意味着(由于启动命令的语法奇),你需要先明确指定窗口标题(也引号)。

Note also the use of %~dpfx0 to determine the full path and name of the current script. This has to be in quotes in case the path contains spaces, which means that (due to the odd syntax of the start command) you need to first explicitly specify a window title (also in quotes).

这篇关于从单一的批处理文件,启动多个shell提示符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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