中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-03 21:29
48,038 topics / 350,123 posts / today 0 new / 48,251 members
DOS批处理 & 脚本技术(批处理室) » How to skip unresponsive programs && question about parallel processing
Printable Version  948 / 11
Floor1 bjsh Posted 2007-03-25 03:14
银牌会员 Posts 621 Credits 2,000
Calling an external program from a batch file;

this program may either run successfully or fail;

if it succeeds, it will probably return to the original batch file in about 2 seconds and continue with the next command;

if it fails, it will take more than 10 seconds to return to the original batch file;

since this is executed in a loop, the execution efficiency becomes very low;

I want to know how to forcibly terminate a program that failed to execute, and directly execute the command below;

that is, only allow the program 3 seconds to run;

if it succeeds, then it will definitely succeed within 3 seconds; and the command below will also be executed;

if it fails, then as soon as 3 seconds are up it will forcibly terminate itself and go execute the command below; I don't know whether this can be done;



Can a batch file execute in parallel?


For example

batch file
|
|
program
|
|
program
|
|
program
|
.
.
.


Can it be made to do this

batch file
|
|
--------------------------------------
| | | | | | | | .....
| | | | | | | |
program program program program program program program program




[ Last edited by bjsh on 2007-3-24 at 02:15 PM ]
Floor2 zh159 Posted 2007-03-25 03:18
金牌会员 Posts 1,467 Credits 3,687
A batch file can only use the "start command" method to open new windows and run multiple commands at the same time; it cannot execute in parallel internally
Floor3 everest79 Posted 2007-03-25 05:06
金牌会员 Posts 1,127 Credits 2,564
You can try it like this
start command
check process static
check process static
check process static
Each time you start a program, check its status three times. If it is not responding even once, then kill it. If not, then start the next one
Floor4 bjsh Posted 2007-03-25 07:25
银牌会员 Posts 621 Credits 2,000
Originally posted by zh159 at 2007-3-24 02:18 PM:
Batch files can only use the "start command" method to open a new window and run multiple commands at the same time; they cannot execute in parallel internally

Mm; yes; I found that out myself too.
Floor5 axi Posted 2007-03-25 22:05
中级用户 Posts 93 Credits 238 From GZ
Originally posted by everest79 at 2007-3-24 16:06:
You can try it like this
start command
check process static
check process static
check process static
After starting each program, check its status three times. If it is non-responsive even once, then kill it; if not, then start the next one.



Isn't check not an internal command? How can you tell that it is not responding? Please advise?
Floor6 everest79 Posted 2007-03-25 22:41
金牌会员 Posts 1,127 Credits 2,564
...I was just giving an example, there is no such command
Floor7 everest79 Posted 2007-03-25 22:43
金牌会员 Posts 1,127 Credits 2,564
For example, the following
Floor8 axi Posted 2007-03-26 01:00
中级用户 Posts 93 Credits 238 From GZ
. batch file
|
|
--------------------------------------
| | | | .....
| | | |
a.exe b.exe c.exe

My PS skills are poor, can it be understood as:

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 ]
Floor9 everest79 Posted 2007-03-26 01:11
金牌会员 Posts 1,127 Credits 2,564
Something like that
Floor10 everest79 Posted 2007-03-26 01:22
金牌会员 Posts 1,127 Credits 2,564
This is what I mean

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 ]
Floor11 axi Posted 2007-03-26 01:51
中级用户 Posts 93 Credits 238 From GZ
Floor12 everest79 Posted 2007-03-26 02:18
金牌会员 Posts 1,127 Credits 2,564
Hehe, I'm getting smarter and smarter
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023