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-06-26 14:52
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » If you want to achieve that running A.bat calls B.bat and then runs C.bat after B.bat is completed. View 2,338 Replies 18
Original Poster Posted 2007-03-20 05:19 ·  IANA 局域网IP(Private-Use)
初级用户
Credits 30
Posts 13
Joined 2007-03-14 00:28
19-year member
UID 81631
Gender Male
Status Offline
There are three batch files, A, B, and C.
A has the function of running B and C.
Want to realize the following function:
Run A.bat, Call B.bat. If B.bat runs successfully, then run C.bat.

In short, run in the order of A, B, C. C.bat should not run before B.bat is finished.

PS: Is there a concept of sleep in DOS?

[ Last edited by ivanisme on 2007-3-20 at 09:16 AM ]
Floor 2 Posted 2007-03-20 06:02 ·  中国 辽宁 朝阳 联通
铂金会员
★★★★
痴迷DOS者
Credits 5,798
Posts 1,924
Joined 2003-06-20 00:00
23-year member
UID 5583
Gender Male
From 金獅電腦軟體工作室
Status Offline
I know but won't answer you. Didn't you read the "Newcomer Must-Read" post on the forum carefully when you registered?
熟能生巧,巧能生精,一艺不精,终生无成,精亦求精,始有所成,臻于完美,永无止境!
金狮電腦軟體工作室愿竭诚为您服务!
QQ群:8393170(定期清理不发言者)
个人网站:http://www.520269.cn
电子邮件:doujiehui@vip.qq.com
微信公众号: doujiehui
Floor 3 Posted 2007-03-20 06:15 ·  IANA 局域网IP(Private-Use)
初级用户
Credits 30
Posts 13
Joined 2007-03-14 00:28
19-year member
UID 81631
Gender Male
Status Offline
Floor 4 Posted 2007-03-20 06:17 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline

  The code in A.bat is just one line: call B.bat&&call C.bat;

  What you mean by sleep is the meaning of delay?
Floor 5 Posted 2007-03-20 06:26 ·  中国 辽宁 朝阳 联通
铂金会员
★★★★
痴迷DOS者
Credits 5,798
Posts 1,924
Joined 2003-06-20 00:00
23-year member
UID 5583
Gender Male
From 金獅電腦軟體工作室
Status Offline
If you want to implement that running A.bat calls B.bat and then runs C.bat after B.bat is completed.
熟能生巧,巧能生精,一艺不精,终生无成,精亦求精,始有所成,臻于完美,永无止境!
金狮電腦軟體工作室愿竭诚为您服务!
QQ群:8393170(定期清理不发言者)
个人网站:http://www.520269.cn
电子邮件:doujiehui@vip.qq.com
微信公众号: doujiehui
Floor 6 Posted 2007-03-20 07:38 ·  IANA 局域网IP(Private-Use)
初级用户
Credits 30
Posts 13
Joined 2007-03-14 00:28
19-year member
UID 81631
Gender Male
Status Offline
Originally posted by lxmxn at 2007-3-19 05:17 PM:

  There is only one line of code in A.bat: call B.bat&&call C.bat;

  Brother, do you mean that sleeping is delaying?


If there are calls to exe in B.bat, it won't work.

Sleeping means delaying, which is thread Sleep
Floor 7 Posted 2007-03-20 07:49 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline
Originally posted by ivanisme at 2007-3-19 18:38:

If there are calls to EXE files in B.bat, it won't work. Sleep is about delaying, which is like thread Sleep.


  If there are EXE files, you can use the start command to call them; start /min "" exefile.exe

  Oh, this can be indirectly achieved by using the ping command to delay; ping 127.1 5 >nul 2>nul, which can delay for about 4 seconds.
Floor 8 Posted 2007-03-20 21:48 ·  IANA 局域网IP(Private-Use)
初级用户
Credits 30
Posts 13
Joined 2007-03-14 00:28
19-year member
UID 81631
Gender Male
Status Offline
The current situation is that there is something that calls an exe in B.bat. C.bat calls other bat files. A.bat still calls B.bat and C.bat (C should be executed after B is completed). Brother lxmxn, do you have any good methods?
Floor 9 Posted 2007-03-20 23:03 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline

Several batch processes can do things, and one batch process can also be completed. Just tell me what purpose you ultimately want to achieve.
Floor 10 Posted 2007-03-20 23:26 ·  IANA 局域网IP(Private-Use)
初级用户
Credits 30
Posts 13
Joined 2007-03-14 00:28
19-year member
UID 81631
Gender Male
Status Offline
The function of this batch processing is: First call an exe program (this takes time), and then run an external bat file (supplied by others). If the exe is not started properly and then the bat is run, it will report an error. So the bat must be run after the exe. I wonder if my expression lxmxn can understand it?
Floor 11 Posted 2007-03-20 23:31 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline
After the exe file runs, there is a delay of about 4 seconds, and then your bat file runs.

@echo off
start exefile.exe
ping 127.1 -n 5 >nul 2>nul
call batfile.bat
Floor 12 Posted 2007-03-21 00:11 ·  IANA 局域网IP(Private-Use)
初级用户
Credits 30
Posts 13
Joined 2007-03-14 00:28
19-year member
UID 81631
Gender Male
Status Offline
Hehe! First of all, thank you for lxmxn's reply.

I tried it and MS works. Just have some questions about -n 5. I checked ntcmds but couldn't figure it out. How is the time controlled? Can't it be controlled?

I'm stupid, hope lxmxn can give me some advice!
Floor 13 Posted 2007-03-21 01:25 ·  中国 上海 东方有线
初级用户
Credits 124
Posts 10
Joined 2004-04-22 00:00
22-year member
UID 23043
Gender Male
Status Offline
If it were me, I would CALL C.BAT in B.BAT, and then put the remaining A.BAT C/P to the end of C.BAT
Floor 14 Posted 2007-03-21 02:10 ·  IANA 局域网IP(Private-Use)
初级用户
Credits 30
Posts 13
Joined 2007-03-14 00:28
19-year member
UID 81631
Gender Male
Status Offline
Originally posted by free2 at 2007-3-20 12:25 PM:
If it were me, I would CALL C.BAT in B.BAT, and then copy the remaining A.BAT C/P to the end of C.BAT

You didn't understand it!
Floor 15 Posted 2007-03-21 02:16 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline

  Re ivanisme:

The ping command has many parameters, among which there are the -n and -w parameters. The -n parameter indicates the number of sent ICMP packets, and the -w parameter indicates the time interval for timeout, meaning if the specified host is not reachable via ping, after how many seconds the packet will be re-sent. By default, the value of the -w parameter is 1000, which represents one second, and the -n parameter specifies the number of sent times. So specifying the -n parameter can determine the amount of delay. Using the principle of planting trees, if you want to delay for n seconds, then the parameter -n is specified as n + 1.

ping 127.1 -n 5 Here, "-n 5" means specifying the value of the -n parameter as 5, so it delays approximately 4 seconds.


[ Last edited by lxmxn on 2007-3-20 at 01:34 PM ]
Forum Jump: