|
Answer» How could I write a batch file to show the message LIKE below and then run the program? 10:00:00 aaa.txt is waiting 5 seconds to start up... 10:00:01 aaa.txt is waiting 4 seconds to start up... 10:00:02 aaa.txt is waiting 3 seconds to start up... 10:00:03 aaa.txt is waiting 2 seconds to start up... 10:00:04 aaa.txt is waiting 1 seconds to start up...
Below is my script:
ECHO OFF setlocal set seconds=%5 if "%seconds%"=="" set seconds=5 ECHO %TIME% aaa.txt is waiting %seconds% seconds to start up... PING 127.0.0.1 -n %seconds% -w 1000 > NUL START /B C:\aaa.txt endlocal exitTry this script, the timing is not precise, you may want to do some work on that.
Code: [Select]echo off cls setlocal enabledelayedexpansion for /l %%1 in (5,-1,1) do ( echo !time:~0,-3! aaa.txt is waiting %%1 second(s^) to STARTUP... ping -n %%1 -w 100000 127.0.0.1 > nul )
start /b "" c:\aaa.txt exit
Finally, I get a solution and want to share with all of you.
Below is my new scripts: echo off set sec=5
:BEGIN if %sec%==0 GOTO END ECHO %TIME% aaa.txt is waiting %sec% seconds to start up... PING 127.0.0.1 -n 2 -w 1000 > NUL set /a sec -=1 CLS goto BEGIN
:END START /B C:\aaa.txtC:\>type wait5.bat
Code: [Select]echo off
ECHO %TIME% aaa.txt is waiting 5 seconds to start up...
C:\batextra\sleep.exe 5 ECHO %TIME%
C:\aaa.txt Output: C:\>wait5.bat 5:14:11.93 aaa.txt is waiting 5 seconds to start up... 5:14:16.98
|