China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-11 00:53
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » How can I make command A finish first and then execute command B? View 879 Replies 3
Original Poster Posted 2008-12-12 23:02 ·  中国 江苏 南京 电信
初级用户
Credits 48
Posts 20
Joined 2007-10-17 01:05
18-year member
UID 99934
Gender Male
Status Offline
I need to implement a batch function similar to using HASH to verify the files in a certain directory, so that the files in directory C and directory D can be kept in sync. The file synchronization is executed through A; after A finishes, then execute B.

How can I make command A finish first and then execute command B? Several ideas don't work:
1. && executes B after A succeeds, but it can't wait for A to finish before executing B, because the execution time is uncertain;
2. Delay: using a delay to control when command B executes still can't solve the timing problem;
3. In the batch file I want to write, A is a Windows application, and the exact parameters are unknown, so its execution time can't be controlled;
4. There is one reliable idea: use a loop to monitor the current process list to see whether process A exists; if process A no longer exists, then execute B. But this approach seems to consume system resources.
5. The effect I want to achieve itself has uncertain timing.

Thanks everyone, I'm asking for advice here.

[ Last edited by nayezi on 2008-12-12 at 23:13 ]
Floor 2 Posted 2008-12-12 23:16 ·  中国 重庆 电信
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
Give the real program names. Nobody knows what programs ABCD are.
Floor 3 Posted 2008-12-14 11:18
初级用户
Credits 34
Posts 36
Joined 2008-12-11 17:21
17-year member
UID 133562
Gender Male
Status Offline
Try this line of thinking and see whether it works. That is, use the errorlevel from executing A; for example, after it executes successfully, then call / call B
爱死DOS亦无悔!
Floor 4 Posted 2008-12-15 17:04 ·  中国 广东 深圳 电信
初级用户
★★
游手好闲 + 无所事事 ..
Credits 194
Posts 167
Joined 2007-04-30 09:43
19-year member
UID 87022
Gender Male
Status Offline
The OP should change the C command mentioned in the subject description. It should be changed to program C.

I guess this is for synchronization in an Internet cafe: wait for synchronization to complete, then execute the follow-up patch. Current synchronization software all has this kind of function, that is, what command to execute after synchronization is complete. For example, lanupdate can do it
Forum Jump: