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-02 06:45
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Ask] How to wait for the started program to end in a batch file? View 2,139 Replies 10
Original Poster Posted 2006-09-28 07:16 ·  IANA 局域网IP(Private-Use)
中级用户
★★
蝴蝶之吻
Credits 430
Posts 177
Joined 2006-09-20 12:00
19-year member
UID 63170
From 广东深圳
Status Offline
I want to ask, can you help me write a batch script for my this problem...

As follows:

After I use the batch script (tmp_1.bat) to open a program, the batch script is minimized, the program runs, when I close the program, this batch script then calls another batch script (tmp_2.bat), and then closes the batch script.

I tried it... didn't succeed....

My Blog ]



————————I am the divider line——————————


*********************************
Moderation Record
*********************************
Operation: Change title
Reason: Original format does not conform to forum rules
Original title: Can my this problem be realized with BAT
Execution: 3742668
Punishment: First offense, pardon.
Remarks: 1. It is suggested to read the sticky forum rules before posting
2. How to change the title?
Click the bottom right corner of the posted thread
Edit button, then edit.
3. DOS batch processing & script technology
(Batch Processing Room) Forum Rules (Draft)
**********************************


[ Last edited by 3742668 on 2006-9-29 at 09:33 ]
Attachments
tmp.JPG
Floor 2 Posted 2006-09-28 07:34 ·  中国 湖南 娄底 新化县 电信
银牌会员
★★★
Credits 1,218
Posts 485
Joined 2006-07-21 21:24
20-year member
UID 58987
From 湖南.娄底
Status Offline
@echo off
***.exe
call tmp_2.bat
...............
pause
Floor 3 Posted 2006-09-28 08:13 ·  IANA 局域网IP(Private-Use)
中级用户
★★
蝴蝶之吻
Credits 430
Posts 177
Joined 2006-09-20 12:00
19-year member
UID 63170
From 广东深圳
Status Offline
Still the same as what I did,,,,,What I want is, when I use ***.EXE, don't execute tmp_2.bat, and only execute tmp_2.bat after I close ***.EXE
Floor 4 Posted 2006-09-28 08:22 ·  中国 甘肃 张掖 电信
金牌会员
★★★★
Credits 4,103
Posts 1,744
Joined 2006-01-20 13:00
20-year member
UID 49241
Gender Male
From 甘肃.临泽
Status Offline
:
The tasklist command is used to list running tasks. The "find "*.exe"" part tries to find processes with the.exe extension. If found, it jumps to the start label. If not found, it starts the *.bat files and then goes to the end of the subroutine. But this might have some issues in terms of proper syntax and functionality in a real Windows command environment. Let's translate the Chinese question "不知道可以否" as "I wonder if this is feasible". So the full translation considering the command and the question is:

tasklist |find "*.exe" &&goto start ||start *.bat &goto :eof
I wonder if this is feasible
Floor 5 Posted 2006-09-28 08:35 ·  中国 湖南 娄底 新化县 电信
银牌会员
★★★
Credits 1,218
Posts 485
Joined 2006-07-21 21:24
20-year member
UID 58987
From 湖南.娄底
Status Offline
When an application is not opened using start, the batch processing will wait until the application finishes before executing the next command.

@echo off
"c:\Program Files\Tencent\qq\QQ.exe"
echo There is no end to learning!
pause
Floor 6 Posted 2006-09-28 08:37 ·  IANA 局域网IP(Private-Use)
中级用户
★★
蝴蝶之吻
Credits 430
Posts 177
Joined 2006-09-20 12:00
19-year member
UID 63170
From 广东深圳
Status Offline
Floor 7 Posted 2006-09-28 09:47 ·  中国 四川 成都 教育网
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline
This issue has been discussed by moderator willsort. For Windows programs called by start, the batch processing will continue to run regardless of whether the program exits or not.

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
Floor 8 Posted 2006-09-28 10:08 ·  中国 广东 佛山 广东睿江科技有限公司
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
start /wait still doesn't work, it seems the help information for start needs to be revised.
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
Floor 9 Posted 2006-09-28 10:24 ·  中国 湖南 娄底 新化县 电信
银牌会员
★★★
Credits 1,218
Posts 485
Joined 2006-07-21 21:24
20-year member
UID 58987
From 湖南.娄底
Status Offline
I finally understand why the original poster's execution didn't succeed. The code I sent is:

@echo off
"c:\Program Files\Tencent\qq\QQ.exe"
echo 学无止境!
pause

而 the original poster changed it to:
@echo off
"c:\Program Files\Tencent\qq\CoralQQ.exe"
echo 学无止境!
pause

Need to note: CoralQQ.exe is the Shanhuhong plug-in, which just calls QQ.exe. When running CoralQQ.exe, it will exit quickly. What appears on the desktop is QQ.exe, not CoralQQ.exe.

CoralQQ.exe ends quickly after running, so it will naturally continue to execute the following commands!
Floor 10 Posted 2006-09-28 10:49 ·  中国 广东 佛山 广东睿江科技有限公司
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
It turns out it was caused by the exit of the alternate account.
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
Floor 11 Posted 2006-09-30 07:22 ·  IANA 局域网IP(Private-Use)
中级用户
★★
蝴蝶之吻
Credits 430
Posts 177
Joined 2006-09-20 12:00
19-year member
UID 63170
From 广东深圳
Status Offline
Hey...These past few days have been really busy...Just now I came to take a look,,,Oh..so it is like this呀..Got it...
Forum Jump: