我想在Windows CMD控制台中运行两个命令.
在Linux中,我会这样做
touch thisfile ; ls -lstrh
Run Code Online (Sandbox Code Playgroud)
它是如何在Windows上完成的?
我有一个主批处理文件,而不是调用其他4个批处理文件,所以我们可以并行运行.
例:
Main.bat
start call batch1.bat
start call batch2.bat
start call batch3.bat
start call batch4.bat
exit
Run Code Online (Sandbox Code Playgroud)
我希望Main.bat在所有batch1到batch 4停止执行后退出.通过这种方式,我可以获得批处理文件的总运行时间.问题是Main.bat甚至在batch1到batch4完成执行之前退出.
我尝试为每个批处理文件计算%errorlevel%,但即使4个.bat文件仍在运行,它总是返回0.
希望有人可以帮助我!
谢谢!:)
我需要并行执行 Python 脚本,因此我使用以下批处理文件:
start python C:\myfolder\1.py
start python C:\myfolder\2.py
start python C:\myfolder\3.py
Run Code Online (Sandbox Code Playgroud)
它工作正常,但现在我需要在上述前三个脚本完成后并行运行三个脚本。如何在同一个批处理文件中指定它?
如何在批处理脚本中并行执行一些任务并等待它们?
command1;
# command3, command4 and command5 should execute in sequence say task1
# command6, command7 and command8 should execute in sequence say task2
# both task1 and task2 should run independently
command3; command4; command5 | command6; command7; command8;
# should execute only after the above parallel tasks are completed
command9;
Run Code Online (Sandbox Code Playgroud)
作为概念验证,我尝试了类似的方法,但是它不起作用:
echo "Starting"
start /wait wait20.bat
start /wait wait40.bat
echo "Finishing"
Run Code Online (Sandbox Code Playgroud)
wait20.bat 看起来像:
echo "starting 20 seconds job"
timeout 20
echo "finishing 20 seconds job"
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?