Board logo

标题: 如何跳过没有响应的程序&&并行处理问题 [打印本页]

作者: bjsh     时间: 2007-3-25 03:14    标题: 如何跳过没有响应的程序&&并行处理问题

从一个批处理中调用外部程序;

这个程序可能执行成功也可能执行失败;

如果成功大概需要2秒钟就能返回到原批处理中继续执行下一条命令;

如果执行失败则需要10秒以上才能返回到原批处理中;

由于是循环执行所以这样下来程序的执行效率很低;

我想如何强行中止执行失败的程序;直接执行下面的命令;

也就是给程序执行的时间为3秒中;

如果成功则在3秒钟之内肯定成功了;也执行了下面的命令;

如果失败则3秒钟一到就自行强行中止;去执行下面的命令; 不知道能否做到;



批处理能否 进行 并行执行;


比如

  Quote:

                批处理
                   |
                   |
                  程序
                   |
                   |
                  程序
                   |
                   |
                  程序
                   |
                   .
                   .
                   .


能否让他实现

  Quote:

                                             批处理
                                                |
                                                |
                                  --------------------------------------
                                  |    |    |    |    |    |    |    |  .....
                                  |    |    |    |    |    |    |    |   
                                程序 程序 程序 程序 程序  程序 程序 程序



[ Last edited by bjsh on 2007-3-24 at 02:15 PM ]
作者: zh159     时间: 2007-3-25 03:18
批处理只能用“start 命令”方式打开新窗口同时运行多个命令,不能在内部并行执行
作者: everest79     时间: 2007-3-25 05:06
你可以这样试试
start command
check process static
check process static
check process static
每启动一个程序你检测它三次状态,若有一次是无响应就K掉,若无则开始下一个
作者: bjsh     时间: 2007-3-25 07:25


  Quote:
Originally posted by zh159 at 2007-3-24 02:18 PM:
批处理只能用“start 命令”方式打开新窗口同时运行多个命令,不能在内部并行执行

嗯;是的;我自己也发现这个了.
作者: axi     时间: 2007-3-25 22:05


  Quote:
Originally posted by everest79 at 2007-3-24 16:06:
你可以这样试试
start command
check process static
check process static
check process static
每启动一个程序你检测它三次状态,若有一次是无响应就K掉,若无则开始下一个

check 不是内部命令?如何得知它没有响应呢? 请赐教?
作者: everest79     时间: 2007-3-25 22:41
...我是举个例子,那有这个命令
作者: everest79     时间: 2007-3-25 22:43
例如以下
tasklist /fi "imagename eq %1" /fi "status ne running"&&taskkill /f "imagenmae eq %1"

作者: axi     时间: 2007-3-26 01:00
.                                           批处理
                                                |
                                                |
                                  --------------------------------------
                                  |           |        |         |  .....
                                  |           |        |         |   
                                a.exe   b.exe   c.exe

小弟P技差劲,是否可以理解为:

start a.exe
tasklist /fi "a.exe eq %1" /fi "status ne running"&&taskkill /f "a.exe eq %1"
start b.exe
tasklist /fi "b.exe eq %1" /fi "status ne running"&&taskkill /f "b.exe eq %1"
......

[ Last edited by axi on 2007-3-25 at 12:03 PM ]
作者: everest79     时间: 2007-3-26 01:11
大概就这样
作者: everest79     时间: 2007-3-26 01:22
我是这样的

start a.exe&&set exefile=%exefile%;"a.exe"
call :chkeck
start b.exe&&set exefile=%exefile%;"b.exe"
call :chkeck
...

:chkeck
for /f "delims=;" %%i in ("%exefile%") do (
taskkill /f /im %%i /fi "status ne running"
)

[ Last edited by everest79 on 2007-3-25 at 12:24 PM ]
作者: axi     时间: 2007-3-26 01:51
e! Thank you!
作者: everest79     时间: 2007-3-26 02:18
嘿嘿,我越来越聪明了