windows - 使用cmd依次打开多个程序

标签 windows cmd fork

我有一系列 3 个程序,必须一个接一个地启动。我在网上发现了类似的东西,这正是我想要做的:

start /wait /b First.exe
start /wait /b Second.exe
start /wait /b Third.exe

我的问题是我有 1000 个序列要启动... 所以我尝试了

start "exemple" "start /wait /b First.exe
start /wait /b Second.exe
start /wait /b Third.exe"
start "exemple2" "start /wait /b First.exe
start /wait /b Second.exe
start /wait /b Third.exe"

我也试过

start /b First1.exe
start /wait /b Second1.exe
start /wait /b Third1.exe

start /b First2.exe
start /wait /b Second2.exe
start /wait /b Third2.exe

这也行不通... 所以我不知道该怎么做。

有什么想法吗? 谢谢:)

[编辑]

让我们试着让它更清晰

start "exemple" "start /wait /b First.exe
start /wait /b Second.exe
start /wait /b Third.exe"
start "exemple2" "start /wait /b First.exe
start /wait /b Second.exe
start /wait /b Third.exe"

失败是因为无法识别第 2 个启动,它表示 Windows 找不到“start/wait/b First.exe”

start /b First1.exe
start /wait /b Second1.exe
start /wait /b Third1.exe

start /b First2.exe
start /wait /b Second2.exe
start /wait /b Third2.exe

这失败了,因为订单是 First1.exe 和 Second1.exe 启动。 然后计算机等待 Second1.exe 结束以启动 First2.exe 和 Second2.exe ...

我想要的顺序是 计算机启动 First1.exe & First2.exe Second1.exe 在 First1.exe 完成时启动,Second2.exe 在 First2.exe 完成时启动。

我想避免每次执行都使用一个 .cmd(这将是我失败的解决方案)。

我希望这次我更清楚!

最佳答案

除了主实例之外,每个序列还需要一个 cmd.exe 实例。操作系统没有对排序进程的内置支持,并且 cmd.exe 不支持命令文件中的线程。

你可以这样做:

 start "sequence1" cmd /c "First.exe & Second.exe & Third.exe"
 start "sequence2" cmd /c "First.exe & Second.exe & Third.exe"
 start "sequence3" cmd /c "First.exe & Second.exe & Third.exe"
 ...

避免 cmd.exe 额外实例的(相当适度的)开销的唯一方法是用真正的编程语言而不是批处理文件编写解决方案。

您可能还需要考虑这是否是您真正想要做的。当数百个进程同时运行时,Windows 通常不会很好地运行。

关于windows - 使用cmd依次打开多个程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7711072/

相关文章:

c# - 无法使用 CommandLineParser 包运行程序

c++ - fork 与父子通信

linux - Rust:如何生成在父级收到SIGINT/SIGTERM之后仍继续存在的子进程

ios - fork() 失败 (1 : Operation not permitted)

c - 如何通过在 Windows 机器上安装 Cygwin 来使用 gcc?

windows - 如何通过 .bat 文件从任务计划程序运行 R 脚本

c - 尝试从命令行运行 Makefile - 无法识别 '.'

cmd - 自动热键脚本打开命令提示符

windows - 内核模式驱动程序可以阻止 Windows 系统启动吗?

windows - 如何唯一标识计算机上的操作系统?