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-07-31 23:33
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Help with Strange Problem]How to achieve delay when START calls internal commands View 1,521 Replies 5
Original Poster Posted 2006-12-30 23:17 ·  中国 广东 东莞 电信
银牌会员
★★★
Credits 1,179
Posts 442
Joined 2006-09-09 22:47
19-year member
UID 62249
Status Offline
Why does the /W parameter of the start command work when starting other programs but not when calling internal commands? I have checked many previous posts and none mentioned the delay of START when calling commands, only when calling other programs.



@echo off
rem To solve the problem that the download is damaged when the computer automatically shuts down after using EMULE to download, this script is written. The idea is as follows:
START /W shutdown -s -t 200
START /W shutdown -a
START XCOPY /S/C/H/R/Y rpl\*.* d:\
shutdown -s -t 100
@echo on

How to make START wait for 200 seconds to complete after executing shutdown -s -t 200 in the above code, then continue to execute shutdown -a and wait for completion, then continue to execute START /W XCOPY /S/C/H/R/Y rpl\*.* d:\, and after the copy is completed, execute shutdown -s -t 100.

Explanation: Although each internal command can be written into a BAT file to achieve, but it is very troublesome when there are many commands. How to solve this problem? Is it really impossible for START to handle internal commands?

[ Last edited by HUNRYBECKY on 2006-12-30 at 11:55 PM ]
Floor 2 Posted 2006-12-31 00:02 ·  中国 广东 东莞 电信
银牌会员
★★★
Credits 1,179
Posts 442
Joined 2006-09-09 22:47
19-year member
UID 62249
Status Offline
Although using start is difficult to achieve the delay of internal commands, but SLEEP can be used to achieve it. The following effect is very good, post it for everyone's reference. Now there is no need to worry about the bad habits of EMULE anymore.
@echo off
rem Solve the problem that the automatic shutdown after using EMULE to download will damage the download, and write this script.
SET /P STIME=How long to shut down later? Enter the time plus lowercase h, m or s, such as 1h means one hour:
SLEEP %STIME%
ECHO Backing up files, please wait.......
if not exist d:\rpl\ md d:\rpl
XCOPY /S/C/H/R/Y d:\emule\temp\*.bak d:\rpl\
shutdown -s -t 100
@echo on
EXIT
Floor 3 Posted 2006-12-31 01:01 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
20-year member
UID 59080
Status Offline

  Can't delay be achieved with ping?
Floor 4 Posted 2006-12-31 01:47
中级用户
★★
DOS之日
Credits 337
Posts 161
Joined 2006-11-04 05:27
19-year member
UID 69523
Gender Male
Status Offline
START Actually, when running a program, if it's an internal CMD command or a batch file, it's called by default with CMD /K, and /K keeps the window open, so it can achieve a delay. But there's a problem: if the CMD command being run is a 32-bit GUI program, the CMD returns to the command prompt without waiting for the application to terminate. If executed in the CMD command line, it doesn't run. So SHUTDOWN returns directly. It seems that it wasn't called with /K.
You can try START /W CMD /K SHUTDOWN -S -T 100.
Here, actually, you can just use CMD directly.
for /f %%h in (`echo hxuan`) do for /f %%x in (`echo hxuan`) do if %%h==%%x nul
Floor 5 Posted 2007-01-03 08:32 ·  中国 广东 东莞 电信
银牌会员
★★★
Credits 1,179
Posts 442
Joined 2006-09-09 22:47
19-year member
UID 62249
Status Offline
Originally posted by hxuan999 at 2006-12-31 01:47:
START Actually, when running a program, if the program being run is an internal CMD command or a batch file, it is defaulted to be called with CMD /K. /K means the window is retained after running the program, so that the delay can be achieved. But there are still questions..



Thank you brother for your answer, but what you gave still doesn't work.
Floor 6 Posted 2007-01-03 08:35 ·  中国 广东 东莞 电信
银牌会员
★★★
Credits 1,179
Posts 442
Joined 2006-09-09 22:47
19-year member
UID 62249
Status Offline
Originally posted by lxmxn at 2006-12-31 01:01:

Can't the delay be achieved using ping?



What I mean by delay is not the delay you mentioned.
I mean how to delay when calling some internal commands, especially when there is a graphical interface.
For example, the command START /W shutdown -s -t 200. I want to wait until the shutdown window closes and finishes before executing another command. Haha, you can try it, it's quite difficult, right.
Forum Jump: