使用cmd依次打开多个程序

发布于 2024-12-09 03:58:39 字数 1415 浏览 1 评论 0原文

我有一系列必须依次启动的 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

这也不起作用...... 所以我不知道该怎么做。

有什么想法吗? thx :)

[编辑]

让我们试着让它更清楚

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"

这失败了,因为第二个启动无法识别,它说 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 (这将是我的失败解决方案)。

我希望这次我能说得更清楚!

i have a sequence of 3 programs that have to be launched one after another. I found on the web something like that wich is exactly what i whant to do :

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

My problem is that i have 1000 sequence to launch...
So i tried

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"

I also tried

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

This is not working too...
So i do not know how to do it.

any idea?
thx :)

[EDIT ]

Let's try to make it more clear

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"

This failed because the 2nd start is not recognized, it says that windows can't find '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

This failed because the order is
First1.exe and Second1.exe are launched.
Then the computer wait the end of Second1.exe to launch First2.exe and Second2.exe ...

The order i would like is
The computer launch First1.exe & First2.exe
Second1.exe is launched when First1.exe finished and Second2.exe is launched when First2.exe finished.

I would like to avoid using one .cmd per execution (this would be my fail solution).

I wish i'm more clear this time!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

绾颜 2024-12-16 03:58:39

除了主实例之外,每个序列还需要一个 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 通常性能不佳。

You will need one instance of cmd.exe for each sequence, in addition to the main instance. The operating system has no built-in support for sequencing processes, and cmd.exe doesn't support threading in command files.

You can do it like this:

 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"
 ...

The only way to avoid the (fairly modest) overhead of the extra instances of cmd.exe would be to write a solution in a real programming language rather than as a batch file.

You may also want to consider whether this is really want you want to do. Windows doesn't typically perform very well when hundreds of processes are running simultaneously.

短叹 2024-12-16 03:58:39

您仍在主批处理文件中等待。您希望第一/第二/第三序列对于每个周期都是独立的。您希望每个周期都有自己的/等待。

start "exempel" cmd /c start /wait First.exe ^& start /wait Second.exe ^& start /wait Third.exe

将其视为向一组助手发出指示。您希望每个助手“等待 First,然后等待 Second,然后等待 Third”。

You are still doing the waiting in the main batch file. You want the First/Second/Third sequence to be independent for each cycle. You want the each cycle to have its own /wait.

start "exempel" cmd /c start /wait First.exe ^& start /wait Second.exe ^& start /wait Third.exe

Think of it as giving instructions to a team of helpers. You want each helper to "wait for First, then wait for Second, then wait for Third."

久光 2024-12-16 03:58:39

在单个 .CMD 文件中添加调用然后通过 start 执行它怎么样?

@echo off
program1.exe
program2.exe
program3.exe

为了检查是否一切正常,您可以测试 .BAT/.CMD 中每个单独程序的返回代码(我的记忆一直告诉我%ERRORLEVEL%,但我对此不太确定:( )

what about adding invocations in a single .CMD file and then execute it via start ?

@echo off
program1.exe
program2.exe
program3.exe

In order to check if everything's ok, you can test the return code of each single progs in .BAT/.CMD (my memory keeps telling me %ERRORLEVEL% but I'm not so sure about it :( )

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文