问题
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?
回答1:
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.
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
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).
回答2:
How about something like:
start cmd /c dir c:\windows
来源:https://stackoverflow.com/questions/7612181/launching-multiple-shell-prompts-from-a-single-batch-file