Create a delay in batch.
Solved
mathhieu
-
CharlesDelo Posted messages 1 Status Membre -
CharlesDelo Posted messages 1 Status Membre -
Hello,
I would like to insert a delay line between two lines in a .bat program but I don't know the syntax, can someone help me? I want to pause for 30 seconds and then continue afterwards.
Thank you
I would like to insert a delay line between two lines in a .bat program but I don't know the syntax, can someone help me? I want to pause for 30 seconds and then continue afterwards.
Thank you
24 réponses
- 1
- 2
Suivant
http://www.robvanderwoude.com/index.html (dead link)
New link: https://www.robvanderwoude.com/wait.php
See the trick using the ping command, which allows you to set a delay in seconds... had to think of that :-)
Webmaster(@)CommentCaMarche.net
>>010000110100001101001101<<
New link: https://www.robvanderwoude.com/wait.php
See the trick using the ping command, which allows you to set a delay in seconds... had to think of that :-)
Webmaster(@)CommentCaMarche.net
>>010000110100001101001101<<
Hi,
PING is not working on all computers
the loop is not precise for time and too variable from one computer to another
so I imagined a wait that takes the system time into account:
@echo off
set pause_time=5
echo pause test: the pause time here is %pause_time% seconds
echo.
call :wait %pause_time%
echo %pause_time% later this message is displayed
echo.
echo the batch will now terminate in 10 seconds
call :wait 10
exit
:wait
call :calculate_time
set /a t1= %j1% + %h1% + %m1% + %s1% + %1
:waiting_loop
call :calculate_time
set /a t2= %j1% + %h1% + %m1% + %s1%
if "%t2%" LSS "%t1%" goto waiting_loop
goto :eof
:calculate_time
set /a jj="100%DATE:~0,2% %% 100"
set /a mm="100%DATE:~3,2% %% 100"
set /a aa=%DATE:~6,4%
rem WARNING put the following 3 lines separated by 1 space on 1 single line
set /a j1="(((1461 * (%aa% + 4800 + (%mm% - 14) / 12)) / 4 + (367 * (%mm% - 2 - 12
* ((%mm% - 14) / 12))) / 12 - (3 * ((%aa% + 4900 + (%mm% - 14) / 12) / 100)) / 4 +
%jj% - 32075) - 2455021) * 86400 "
set /a h1= %time:~0,2% * 3600
set /a m1= %time:~3,2% * 60
set s1=%time:~6,2%
it's a bit heavy but reliable on all machines!
PING is not working on all computers
the loop is not precise for time and too variable from one computer to another
so I imagined a wait that takes the system time into account:
@echo off
set pause_time=5
echo pause test: the pause time here is %pause_time% seconds
echo.
call :wait %pause_time%
echo %pause_time% later this message is displayed
echo.
echo the batch will now terminate in 10 seconds
call :wait 10
exit
:wait
call :calculate_time
set /a t1= %j1% + %h1% + %m1% + %s1% + %1
:waiting_loop
call :calculate_time
set /a t2= %j1% + %h1% + %m1% + %s1%
if "%t2%" LSS "%t1%" goto waiting_loop
goto :eof
:calculate_time
set /a jj="100%DATE:~0,2% %% 100"
set /a mm="100%DATE:~3,2% %% 100"
set /a aa=%DATE:~6,4%
rem WARNING put the following 3 lines separated by 1 space on 1 single line
set /a j1="(((1461 * (%aa% + 4800 + (%mm% - 14) / 12)) / 4 + (367 * (%mm% - 2 - 12
* ((%mm% - 14) / 12))) / 12 - (3 * ((%aa% + 4900 + (%mm% - 14) / 12) / 100)) / 4 +
%jj% - 32075) - 2455021) * 86400 "
set /a h1= %time:~0,2% * 3600
set /a m1= %time:~3,2% * 60
set s1=%time:~6,2%
it's a bit heavy but reliable on all machines!
yes it's very good, it works very well and there are plenty of programs that allow for a pause such as Delay, Sleep, Wait, Waitn and others but they are NOT included with Windows XP or Vista and therefore require downloading additional software into system32 or the execution folder which limits the portability of a script to its own computer or that of informed users.
the goal without any pretension of the previous script (call :wait x) is to find a trick to manage this type of pause without calling additional external software to the "classic" package.
You may have noticed that it might be considered superfluous to take into account the number of days since a date, but even if it creates a somewhat crazy line, it prevents an infinite loop if the function is called at 11:59 and 58 seconds (!)
it should also be noted that at home, ping 127.0.0.1 -n 5 >nul, or ping -n 1 1.1.1.1 -w 5000 >nul work very well with a "normally configured" network.
To date, it seems to work correctly on computers of different generations and different systems (xp 2000 vista)
the goal without any pretension of the previous script (call :wait x) is to find a trick to manage this type of pause without calling additional external software to the "classic" package.
You may have noticed that it might be considered superfluous to take into account the number of days since a date, but even if it creates a somewhat crazy line, it prevents an infinite loop if the function is called at 11:59 and 58 seconds (!)
it should also be noted that at home, ping 127.0.0.1 -n 5 >nul, or ping -n 1 1.1.1.1 -w 5000 >nul work very well with a "normally configured" network.
To date, it seems to work correctly on computers of different generations and different systems (xp 2000 vista)
simplified version of the waiting loop that works on all computers and without special behavior parameters or specific program
@echo off
echo.
echo waiting loop test under dos
echo calling the routine for 6 seconds of waiting
call :wait 6
echo the wait (6 seconds) is over, the script can continue
pause
goto eof
:wait
rem to call this routine (time in seconds) call :wait 5
call :calculateTime
set /a t1= %t2% + %1
:waitingLoop
call :calculateTime
if "%t2%" LSS "%t1%" goto waitingLoop
goto :eof
:calculateTime
set /a h1= %time:~0,2% * 3600 1>nul 2>nul
set /a m1= %time:~3,2% * 60 1>nul 2>nul
set s1=%time:~6,2% 1>nul 2>nul
set /a t2= %h1% + %m1% + %s1% 1>nul 2>nul
goto :eof
@echo off
echo.
echo waiting loop test under dos
echo calling the routine for 6 seconds of waiting
call :wait 6
echo the wait (6 seconds) is over, the script can continue
pause
goto eof
:wait
rem to call this routine (time in seconds) call :wait 5
call :calculateTime
set /a t1= %t2% + %1
:waitingLoop
call :calculateTime
if "%t2%" LSS "%t1%" goto waitingLoop
goto :eof
:calculateTime
set /a h1= %time:~0,2% * 3600 1>nul 2>nul
set /a m1= %time:~3,2% * 60 1>nul 2>nul
set s1=%time:~6,2% 1>nul 2>nul
set /a t2= %h1% + %m1% + %s1% 1>nul 2>nul
goto :eof
more comprehensive version taking into account the day change, remaining time display, and final beep
@echo off
echo.
echo waiting loop test under dos
call :wait 12
pause
goto eof
:wait
rem to call this routine (time in seconds) call :wait 5
set c2=.
set c3=%1
echo calling the routine for %1 seconds of waiting
call :calculatetime
set /a t1a= %t2%
set /a t1= %t2% + %1
rem possibly add 2 spaces after waiting
(Set /P paf= waiting ) <NUL
:waitloop
call :calculatetime
set /a c1= %t2% - %t1a%
if %c1% LSS 0 (
set /a c1= 0
set /a c3= %t1% - 86400
set /a c2= %t1% - 86400
set /a t1a= 0
set /a t1= %t1% - 86400
)
:clear
rem if does not work
rem delete the space that is placed at copying and pasting at the end of the next line: set c2=%c2:~0,-1%
set c2=%c2:~0,-1%
rem paf= backspace character obtained with alt 008 with notepad++
(Set /P paf=) <NUL
if not "%c2%"=="" goto clear
set /a c2=%c3% - %c1%
(Set /P paf=%c2%s ) <NUL
if not %c2% leq 0 goto waitloop
(Set /P paf=) <NUL
echo the wait of %1s is over the script continues
rem sound via motherboard: character: alt 007
echo
rem sound via sound card
rundll32 user32.dll,MessageBeep
goto :eof
:calculatetime
set /a h1= %time:~0,2% * 3600 1>nul 2>&1
set /a m1= %time:~3,2% * 60 1>nul 2>&1
set s1=%time:~6,2% 2>&1
set /a t2= %h1% + %m1% + %s1% 1>nul 2>&1
goto :eof
@echo off
echo.
echo waiting loop test under dos
call :wait 12
pause
goto eof
:wait
rem to call this routine (time in seconds) call :wait 5
set c2=.
set c3=%1
echo calling the routine for %1 seconds of waiting
call :calculatetime
set /a t1a= %t2%
set /a t1= %t2% + %1
rem possibly add 2 spaces after waiting
(Set /P paf= waiting ) <NUL
:waitloop
call :calculatetime
set /a c1= %t2% - %t1a%
if %c1% LSS 0 (
set /a c1= 0
set /a c3= %t1% - 86400
set /a c2= %t1% - 86400
set /a t1a= 0
set /a t1= %t1% - 86400
)
:clear
rem if does not work
rem delete the space that is placed at copying and pasting at the end of the next line: set c2=%c2:~0,-1%
set c2=%c2:~0,-1%
rem paf= backspace character obtained with alt 008 with notepad++
(Set /P paf=) <NUL
if not "%c2%"=="" goto clear
set /a c2=%c3% - %c1%
(Set /P paf=%c2%s ) <NUL
if not %c2% leq 0 goto waitloop
(Set /P paf=) <NUL
echo the wait of %1s is over the script continues
rem sound via motherboard: character: alt 007
echo
rem sound via sound card
rundll32 user32.dll,MessageBeep
goto :eof
:calculatetime
set /a h1= %time:~0,2% * 3600 1>nul 2>&1
set /a m1= %time:~3,2% * 60 1>nul 2>&1
set s1=%time:~6,2% 2>&1
set /a t2= %h1% + %m1% + %s1% 1>nul 2>&1
goto :eof
Hello; it works if you're interested; use worpad.exe for accents and more:
=> With worpad.exe you can save a file in MS-DOS text format (oem/ansi).
CRC32: 51E5549F
MD5: F78BD9F46E877C48C5E48DB09CB9F361
SHA-1: 3D1780F8DF5C5ADBD32B70AC573891305416C7D1
SHA-256: A3C85571AD1C080B58B64417D8971FC20E6A02BAEA8C97F7AC85F2C46A2C4B4F
test20120129-22h26.bat
It's very difficult to find certain errors like an echo file blocking 'echo.'
See you; the goal is to create a hexadecimal counter and more...
=> With worpad.exe you can save a file in MS-DOS text format (oem/ansi).
CRC32: 51E5549F
MD5: F78BD9F46E877C48C5E48DB09CB9F361
SHA-1: 3D1780F8DF5C5ADBD32B70AC573891305416C7D1
SHA-256: A3C85571AD1C080B58B64417D8971FC20E6A02BAEA8C97F7AC85F2C46A2C4B4F
test20120129-22h26.bat
@echo off setlocal cls echo €a starts ... echo. set varadd=0 set varnombre=0 rem 0 = 00 to 15 ; 1 = 16 to 255 set vardecihexaright=0 rem 0 = 0x00 to 0x09 ; 1 = 0x10 to 0x0F set varhexaright=0 rem 0 = 00 to 15 ; 1 = 16 to 255 set vardecihexaleft=0 rem 0 = 0x00 to 0x09 ; 1 = 0x10 to 0xFF set varhexaleft=0 :astc set /a varadd=%varnombre%+1 set varnombre=%varadd% echo %varnombre% set varnbrighthexa="%varnombre%" if "%varnombre%" == "10" (set varnbrighthexa="A") if "%varnombre%" == "11" (set varnbrighthexa="B") if "%varnombre%" == "12" (set varnbrighthexa="C") if "%varnombre%" == "13" (set varnbrighthexa="D") if "%varnombre%" == "14" (set varnbrighthexa="E") if "%varnombre%" == "15" (set varnbrighthexa="F") set varnbrlefthexa="%varnombre%" if "%varnombre%" == "10" (set varnbrlefthexa="A") if "%varnombre%" == "11" (set varnbrlefthexa="B") if "%varnombre%" == "12" (set varnbrlefthexa="C") if "%varnombre%" == "13" (set varnbrlefthexa="D") if "%varnombre%" == "14" (set varnbrlefthexa="E") if "%varnombre%" == "15" (set varnbrlefthexa="F") set stocknbrhexa=%varnbrlefthexa%%varnbrighthexa% echo %stocknbrhexa% rem **** rem delay rem http://support.microsoft.com/kb/460936/ rem http://www.commentcamarche.net/forum/affich-2047032-faire-une-attente-sous-dos-batch set secondbegin=%time:~6,2% set /a secondelay=%secondbegin%+1 set secondtest=%secondelay% if "%secondtest%" == "60" (set secondtest=1) if "%secondtest%" == "61" (set secondtest=2) if "%secondtest%" == "62" (set secondtest=3) :paustmp rem pause set secondactueltest=%time:~6,2% rem echo %secondtest% rem echo %secondactueltest% if not %secondactueltest% geq %secondtest% (goto paustmp) rem **** if "%varnombre%" equ "15" (goto fin) goto astc goto answer%ERRORLEVEL% :answer0 echo The program returned code 0 goto suite :answer1 echo The program returned code 1 :suite echo. pause :fin endlocal exit /B
It's very difficult to find certain errors like an echo file blocking 'echo.'
See you; the goal is to create a hexadecimal counter and more...
http://www.ss64.com/nt/
http://www.robvanderwoude.com/choice.html (thanks Jeff)
--
Happy New Year 2006.
http://www.robvanderwoude.com/choice.html (thanks Jeff)
--
Happy New Year 2006.
JP : Zen, mes Nuggets ! ;-) Knowledge is only valuable when it is shared.
yop
there is a very simple solution that doesn't clutter the script with the software "delay" that many don't know about because choice is not compatible with XP :p
so download delay here http://users.csc.calpoly.edu/~bfriesen/software/files/delay32.zip
unzip it in Windows and now you just have to set the time. I'll give you an example of a script
@echo off
start notepad.exe
@echo waiting 30 seconds before resuming
delay 30
@echo waiting finished
start calc.exe
pause
so this is a simple example to show you, we launch notepad then the message @echo waiting 30 seconds before resuming is displayed, then the countdown starts, after 30 seconds the text waiting finished appears and launches the calculator. I've added a pause at the end so that the window stays open, but you can remove it :)
so the finished script looks like this
waiting 30 seconds before resuming
Pausing for 0
waiting finished
Press any key to continue...
so this example I made it as simple as possible
for the time, you just have to change the time next to "delay"
there you go
there is a very simple solution that doesn't clutter the script with the software "delay" that many don't know about because choice is not compatible with XP :p
so download delay here http://users.csc.calpoly.edu/~bfriesen/software/files/delay32.zip
unzip it in Windows and now you just have to set the time. I'll give you an example of a script
@echo off
start notepad.exe
@echo waiting 30 seconds before resuming
delay 30
@echo waiting finished
start calc.exe
pause
so this is a simple example to show you, we launch notepad then the message @echo waiting 30 seconds before resuming is displayed, then the countdown starts, after 30 seconds the text waiting finished appears and launches the calculator. I've added a pause at the end so that the window stays open, but you can remove it :)
so the finished script looks like this
waiting 30 seconds before resuming
Pausing for 0
waiting finished
Press any key to continue...
so this example I made it as simple as possible
for the time, you just have to change the time next to "delay"
there you go
slt
I found this in Windows 7 x64 Home Premium; to test:
+
* TIMEOUT /T 10 | echo test to change the text
* TIMEOUT /T 10 > nul to see nothing
* TIMEOUT /T 10 > nul | echo test cumulative without further effect(s)
2 questions, please; thank you:
How to RE-write on the same line without line breaks (e.g., with echo)?
With "title /?" = "Sets the title of the window for a DOS window" yes but that is a limited trick and not a direct answer to the question posed.
How to retrieve the codes of the pressed keys (multiple)?
With NOBREAK you can press multiple times on the keyboard...
Pausing is good, but you need to be able to test what the user did upon exit, in order to make better proposals = conditional test (if then else). And in the command help, you can't find the codes for the special variable %ERRORLEVEL% (echo %ERRORLEVEL% = 0); even if we don't have the key code directly, although with the command "choice /?" it works but you must only use the chosen keys and not any key to exit (besides the optional timeout before defining a mandatory default choice).
Thank you in advance
Looking forward to hearing from you
I found this in Windows 7 x64 Home Premium; to test:
C:\Users\%USERNAME%>timeout /? TIMEOUT /T timeout_period /NOBREAK Description: This utility accepts a timeout parameter that defines the waiting period (in seconds) or until a key press occurs. It also accepts a parameter to ignore key usage. Parameter list: /T maximum_timeout Specifies the number of seconds to wait. The valid range is between -1 and 99999 seconds. /NOBREAK Ignore key usage and wait the indicated time. /? Displays this help message. Note: A timeout value of -1 means a key press is expected. Examples: TIMEOUT /? TIMEOUT /T 10 TIMEOUT /T 300 /NOBREAK TIMEOUT /T -1 C:\Users\%USERNAME%>
+
* TIMEOUT /T 10 | echo test to change the text
* TIMEOUT /T 10 > nul to see nothing
* TIMEOUT /T 10 > nul | echo test cumulative without further effect(s)
2 questions, please; thank you:
How to RE-write on the same line without line breaks (e.g., with echo)?
With "title /?" = "Sets the title of the window for a DOS window" yes but that is a limited trick and not a direct answer to the question posed.
How to retrieve the codes of the pressed keys (multiple)?
With NOBREAK you can press multiple times on the keyboard...
Pausing is good, but you need to be able to test what the user did upon exit, in order to make better proposals = conditional test (if then else). And in the command help, you can't find the codes for the special variable %ERRORLEVEL% (echo %ERRORLEVEL% = 0); even if we don't have the key code directly, although with the command "choice /?" it works but you must only use the chosen keys and not any key to exit (besides the optional timeout before defining a mandatory default choice).
Thank you in advance
Looking forward to hearing from you
slt re ; I found a trick but it's not perfect at all; even though it works:
How to RE-write on the same line without line breaks (e.g., with echo)?
It will blink a lot (even more) if timeout is not set to 1 second or more.
It blinks too much and rewriting multiple lines slows down the overall process...
You can make a film; an animation :*-))!
1021 bytes (1,021 bytes)
CRC32: 6909C08A
MD5: 474611FB4C07B8156D0EE0305D98FB06
SHA-1: B8C14C04050299424BD5B4E4C40D06EEB33F97BE
SHA-256: 40DBC0295833B82085A581CAE5B3848599C7CD031E2BD3589315C8778248B5A4
With the mouse, you can't copy; the window clears when you click ;-)); that might be useful.
Likewise, via the menu... ;-)); and in both cases, the program (the counter) is paused.
Press any key (focus in the command prompt) to continue :--)!
(( It should be possible to test if the screen is blank for more than 1 second or if it's normal?
Then act accordingly...; game, test, ... ))
The hexadecimal counter doesn't work as I would like (unless there's a code error) because the result seems to only be available in decimal format even though it’s good to be able to add a hexadecimal number by adding it (for example) to another.
Looking forward to hearing from you.
How to RE-write on the same line without line breaks (e.g., with echo)?
It will blink a lot (even more) if timeout is not set to 1 second or more.
It blinks too much and rewriting multiple lines slows down the overall process...
You can make a film; an animation :*-))!
@echo off setlocal set varadd=0 set varnombre=0 set damier=1 :astc set /a varadd=%varadd%+(0x01) set varnombre=%varadd% mode con:lines=25 : echo Start test ... echo. echo demo to display a counter without line breaks with echo echo. echo this is not perfect at all (blinking) but it works echo. echo Tip = mode con:lines=25 (25 can come from a variable) echo. if %damier%==2 (goto damier2) echo ÜßÜßÜßÜßÜßÜßÜßÜß echo ÜßÜßÜßÜßÜßÜßÜßÜß echo ÜßÜßÜßÜßÜßÜßÜßÜß THE CHECKERBOARD CHANGES SHAPE 8=)) echo ÜßÜßÜßÜßÜßÜßÜßÜß echo ÜßÜßÜßÜßÜßÜßÜßÜß set damier=2 goto findamier1 :damier2 echo ßÜßÜßÜßÜßÜßÜßÜßÜ echo ßÜßÜßÜßÜßÜßÜßÜßÜ echo ßÜßÜßÜßÜßÜßÜßÜßÜ THE CHECKERBOARD CHANGES SHAPE 8=)) echo ßÜßÜßÜßÜßÜßÜßÜßÜ echo ßÜßÜßÜßÜßÜßÜßÜßÜ set damier=1 :findamier1 echo. : echo counter %varnombre% if /i %varnombre% geq 20 goto eof echo. echo Exit when the counter displays 20 timeout /T 1 > nul goto astc :eof echo. echo exit of the test echo. pause endlocal exit
1021 bytes (1,021 bytes)
CRC32: 6909C08A
MD5: 474611FB4C07B8156D0EE0305D98FB06
SHA-1: B8C14C04050299424BD5B4E4C40D06EEB33F97BE
SHA-256: 40DBC0295833B82085A581CAE5B3848599C7CD031E2BD3589315C8778248B5A4
With the mouse, you can't copy; the window clears when you click ;-)); that might be useful.
Likewise, via the menu... ;-)); and in both cases, the program (the counter) is paused.
Press any key (focus in the command prompt) to continue :--)!
(( It should be possible to test if the screen is blank for more than 1 second or if it's normal?
Then act accordingly...; game, test, ... ))
The hexadecimal counter doesn't work as I would like (unless there's a code error) because the result seems to only be available in decimal format even though it’s good to be able to add a hexadecimal number by adding it (for example) to another.
Looking forward to hearing from you.
Hi there; my dancer is cool :-D)
Danseur20120201-01h53m00-1610octectsCRC32=948DD4CF.bat
1.57 Ko (1,610 bytes)
CRC32: 948DD4CF
MD5: EFA9EB26A850F1A8BB69A247C5A49624
SHA-1: 152879D27142AE6D6318CEB418E624107D6C8686
SHA-256: 1BCA815A2E24D4C87489D8B67EAD1C1A6C3C76794773632671DEB9198897D7C2
(( POC Download with Hash+Size => GégènBinaire | CommentCaMarche :
http://www.commentcamarche.net/forum/affich-24282430-poc-download-avec-hash-taille-gegenbinaire ))
Looking forward to hearing from you :*-))
Danseur20120201-01h53m00-1610octectsCRC32=948DD4CF.bat
1.57 Ko (1,610 bytes)
CRC32: 948DD4CF
MD5: EFA9EB26A850F1A8BB69A247C5A49624
SHA-1: 152879D27142AE6D6318CEB418E624107D6C8686
SHA-256: 1BCA815A2E24D4C87489D8B67EAD1C1A6C3C76794773632671DEB9198897D7C2
(( POC Download with Hash+Size => GégènBinaire | CommentCaMarche :
http://www.commentcamarche.net/forum/affich-24282430-poc-download-avec-hash-taille-gegenbinaire ))
@echo off setlocal set varadd=0 set varnombre=0 set danse=1 set damier=1 :astc set /a varadd=%varadd%+(0x01) set varnombre=%varadd% mode con:lines=25 : echo Start test ... echo. echo demo to display a counter without line breaks with echo echo. echo this is not perfect at all (flickering) but it works echo. echo Tip = mode con:lines=25 (25 can come from a variable) echo. : if not %danse%==1 goto danse2 echo o echo (\ dance with me 8-D) echo /\ set danse=2 goto dansefincycle : :danse2 if not %danse%==2 goto danse3 echo o echo = dance with me 8-D) echo /\ set danse=3 goto dansefincycle : :danse3 if not %danse%==3 goto danse4 echo \o/ echo ) dance with me 8-D) echo /\ set danse=4 goto dansefincycle : :danse4 if not %danse%==4 goto dansefincycle echo o echo )= dance with me 8-D) echo /\ set danse=1 :dansefincycle : echo. : if %damier%==2 (goto damier2) echo ÜßÜßÜßÜßÜßÜßÜßÜß echo ÜßÜßÜßÜßÜßÜßÜßÜß echo ÜßÜßÜßÜßÜßÜßÜßÜß THE CHECKERBOARD CHANGES SHAPE 8=)) echo ÜßÜßÜßÜßÜßÜßÜßÜß echo ÜßÜßÜßÜßÜßÜßÜßÜß set damier=2 goto findamier1 :damier2 echo ßÜßÜßÜßÜßÜßÜßÜßÜ echo ßÜßÜßÜßÜßÜßÜßÜßÜ echo ßÜßÜßÜßÜßÜßÜßÜßÜ THE CHECKERBOARD CHANGES SHAPE 8=)) echo ßÜßÜßÜßÜßÜßÜßÜßÜ echo ßÜßÜßÜßÜßÜßÜßÜßÜ set damier=1 :findamier1 echo. : echo counter %varnombre% if /i %varnombre% geq 20 goto eof echo. echo Exit when the counter displays 20 timeout /T 1 > nul goto astc :eof echo. echo test exit echo. pause endlocal exit
Looking forward to hearing from you :*-))
slt ; dancer version with bonus (previous versions destroyed) :
Dancer20120201-03h31m00-2546octectsCRC32=20725800.bat
2.48 Ko (2 546 bytes)
CRC32: 20725800
MD5: 8B91019EBBDE66DAAA4837E721BA4839
SHA-1: 3EA1990AE3DC89927B2C8E709A615B372951807F
SHA-256: AD67D4B2F68D6DB4C4FB187EEFE2401FAA76B6989FA981B79BD544927F4741E0
There is a trap missing at the end on the dancefloor and screams in text, nooo ... :-))
looking forward to your response :*-))
Dancer20120201-03h31m00-2546octectsCRC32=20725800.bat
2.48 Ko (2 546 bytes)
CRC32: 20725800
MD5: 8B91019EBBDE66DAAA4837E721BA4839
SHA-1: 3EA1990AE3DC89927B2C8E709A615B372951807F
SHA-256: AD67D4B2F68D6DB4C4FB187EEFE2401FAA76B6989FA981B79BD544927F4741E0
@echo off setlocal set varadd=0 set varnombre=0 set danse=1 set damier=1 :astc set /a varadd=%varadd%+(0x01) set varnombre=%varadd% mode con:lines=25 : echo Start test ... echo. echo demo to display a counter without skipping lines with echo echo. echo this is not perfect at all (flickering) but it works echo. echo Tip = mode con:lines=25 (25 can come from a variable) echo. : :danse1 if not %danse%==1 goto danse2 echo o echo (\ dance with me 8-D) echo /\ set danse=2 goto dansefincycle : :danse2 if not %danse%==2 goto danse3 echo o echo = dance with me 8-D) echo /\ set danse=3 goto dansefincycle : :danse3 if not %danse%==3 goto danse4 echo \o/ echo ) dance with me 8-D) echo /\ set danse=4 goto dansefincycle : :danse4 if not %danse%==4 goto danse5 echo o echo )= dance with me 8-D) echo /\ set danse=5 goto dansefincycle : :danse5 if not %danse%==5 goto danse6 echo o echo (\ dance with me 8,-D) echo /\ set danse=6 goto dansefincycle : :danse6 if not %danse%==6 goto danse7 echo o echo = dance with me 8,-D) echo /\ set danse=7 goto dansefincycle : :danse7 if not %danse%==7 goto danse8 echo \o/ echo ) dance with me 8-D) echo /\ set danse=8 goto dansefincycle : :danse8 if not %danse%==8 goto dansefincycle echo o echo )= dance with me 8-D) echo /\ set danse=1 :dansefincycle : echo. : if %damier%==2 (goto damier2) echo ÜßÜßÜßÜßÜßÜßÜßÜß echo ÜßÜßÜßÜßÜßÜßÜßÜß if not %danse%==7 goto dansedamier1 echo ÜßÜßÜßÜßÜßÜßÜßÜß THE CHECKERBOARD CHANGES SHAPE 8;=D)) :dansedamier1 if %danse%==7 goto finsouriredamier1 echo ÜßÜßÜßÜßÜßÜßÜßÜß THE CHECKERBOARD CHANGES SHAPE 8=)) :finsouriredamier1 echo ÜßÜßÜßÜßÜßÜßÜßÜß echo ÜßÜßÜßÜßÜßÜßÜßÜß set damier=2 goto findamier1 :damier2 echo ßÜßÜßÜßÜßÜßÜßÜßÜ echo ßÜßÜßÜßÜßÜßÜßÜßÜ if not %danse%==7 goto dansedamier2 echo ßÜßÜßÜßÜßÜßÜßÜßÜ THE CHECKERBOARD CHANGES SHAPE 8;=D)) :dansedamier2 if %danse%==7 goto finsouriredamier2 echo ßÜßÜßÜßÜßÜßÜßÜßÜ THE CHECKERBOARD CHANGES SHAPE 8=)) :finsouriredamier2 echo ßÜßÜßÜßÜßÜßÜßÜßÜ echo ßÜßÜßÜßÜßÜßÜßÜßÜ set damier=1 :findamier1 echo. : echo counter %varnombre% if /i %varnombre% geq 20 goto eof echo. echo Exit when the counter reaches 20 timeout /T 1 > nul goto astc :eof echo. echo exit the test echo. pause endlocal exit
There is a trap missing at the end on the dancefloor and screams in text, nooo ... :-))
looking forward to your response :*-))
C:\>choice /t:o,30>nul
'choice' is not recognized as an internal or external command, operable program or batch file.
C:\>
-???
'choice' is not recognized as an internal or external command, operable program or batch file.
C:\>
-???
Hi,
Availability
Choice.com a été initialement fourni sur le CD d'installation de Windows 95, cependant il y a quelques problèmes avec cette version sous NT - des invocations multiples et concurrentes de CHOICE se chevauchent. CHOICE.com consommera également beaucoup de CPU lorsqu'il est en état d'attente.
Les kits de ressources NT et 2000 contiennent CHOICE.EXE qui se comporte beaucoup mieux.
Dans Windows 2003, CHOICE est devenu une commande intégrée, il n'est donc plus dans le kit de ressources.
http://www.ss64.com/nt/choice.html
--
Z'@+...che and Happy New Year 2006.
Availability
Choice.com a été initialement fourni sur le CD d'installation de Windows 95, cependant il y a quelques problèmes avec cette version sous NT - des invocations multiples et concurrentes de CHOICE se chevauchent. CHOICE.com consommera également beaucoup de CPU lorsqu'il est en état d'attente.
Les kits de ressources NT et 2000 contiennent CHOICE.EXE qui se comporte beaucoup mieux.
Dans Windows 2003, CHOICE est devenu une commande intégrée, il n'est donc plus dans le kit de ressources.
http://www.ss64.com/nt/choice.html
--
Z'@+...che and Happy New Year 2006.
JP: Zen, mes Nuggets ! ;-) Le savoir n'est bon que s'il est partagé.
@echo off
setlocal enableextensions
setlocal enabledelayedexpansion
rem
rem routine de pause DOS rudimentaire (0-59 sec)
rem
set sl=%1
if defined sl (
if !sl! gtr 59 (
echo.
echo Temps d'attente maximum. 59 sec.
echo.
goto :end_script
)
call :sleep %sl%
) else (
set /p sl=Entrez le temps de pause ^(0-59 sec^):
if !sl! gtr 59 (
echo.
echo Temps d'attente maximum. 59 sec.
echo.
goto :end_script
)
call :sleep !sl!
)
goto :end_script
:sleep
if not defined 2 (
set /a w_time=0
) else (
set /a w_time=%2
)
for /f "tokens=4 delims=:" %%i in ('echo. ^| time') do (
set t1=N%%i
set t1=!t1:N00.0=!
set t1=!t1:N00=!
set t1=!t1:N0=!
set t1=!t1:N=!
set t1s=!t1:.=!
set /a t1f=!t1s!
)
:s_time
for /f "tokens=4 delims=:" %%i in ('echo. ^| time') do (
set t2=N%%i
set t2=!t2:N00.0=!
set t2=!t2:N00=!
set t2=!t2:N0=!
set t2=!t2:N=!
set t2s=!t2:.=!
set /a t2f=!t2s!
)
if !t2f! lss !t1f! set /a t2f=!t2f!+6000
set /a w_time=!t2f!-!t1f!
set /a m_time=%1*100
if !w_time! leq !m_time! goto :s_time %1 !w_time!
goto :end_sleep
:end_sleep
:end_script
endlocal
setlocal enableextensions
setlocal enabledelayedexpansion
rem
rem routine de pause DOS rudimentaire (0-59 sec)
rem
set sl=%1
if defined sl (
if !sl! gtr 59 (
echo.
echo Temps d'attente maximum. 59 sec.
echo.
goto :end_script
)
call :sleep %sl%
) else (
set /p sl=Entrez le temps de pause ^(0-59 sec^):
if !sl! gtr 59 (
echo.
echo Temps d'attente maximum. 59 sec.
echo.
goto :end_script
)
call :sleep !sl!
)
goto :end_script
:sleep
if not defined 2 (
set /a w_time=0
) else (
set /a w_time=%2
)
for /f "tokens=4 delims=:" %%i in ('echo. ^| time') do (
set t1=N%%i
set t1=!t1:N00.0=!
set t1=!t1:N00=!
set t1=!t1:N0=!
set t1=!t1:N=!
set t1s=!t1:.=!
set /a t1f=!t1s!
)
:s_time
for /f "tokens=4 delims=:" %%i in ('echo. ^| time') do (
set t2=N%%i
set t2=!t2:N00.0=!
set t2=!t2:N00=!
set t2=!t2:N0=!
set t2=!t2:N=!
set t2s=!t2:.=!
set /a t2f=!t2s!
)
if !t2f! lss !t1f! set /a t2f=!t2f!+6000
set /a w_time=!t2f!-!t1f!
set /a m_time=%1*100
if !w_time! leq !m_time! goto :s_time %1 !w_time!
goto :end_sleep
:end_sleep
:end_script
endlocal
Hello
good script, but it doesn't work under DOS with locale settings "France" because in time the dot is replaced by a comma.
So you need to add the following line to replace this comma (if it exists) with a dot
after set t1=N%%i you need to add
set t1=!t1:,=.!
and after set t2=N%%i you need to add
set t2=!t2:,=!
good script, but it doesn't work under DOS with locale settings "France" because in time the dot is replaced by a comma.
So you need to add the following line to replace this comma (if it exists) with a dot
after set t1=N%%i you need to add
set t1=!t1:,=.!
and after set t2=N%%i you need to add
set t2=!t2:,=!
sorry but under XP, it doesn't work anymore :
------------------------------------------
C:\Documents and Settings\Administrator.TITANIUM>CHOICE do you like me ?
'CHOICE' is not recognized as an internal
or external command, an executable program, or a batch file.
------------------------------------------
------------------------------------------
C:\Documents and Settings\Administrator.TITANIUM>CHOICE do you like me ?
'CHOICE' is not recognized as an internal
or external command, an executable program, or a batch file.
------------------------------------------
Well yes, I know that, but I'm looking for something that works automatically without needing to touch anything. So pause is not going to work. :(
Thanks anyway, if you have other ideas I'm all ears...
Thanks anyway, if you have other ideas I'm all ears...
Sorry, I think my suggestion box is empty. Unless you write your own interpreter, I don't see any other solutions. Or you could maybe write a small command-line program that you call in your batch by passing it the duration of its execution like this:
copy ...
wait 60
...
copy ...
wait 60
...
Colle ça dans "system32" (après le démarrage) : http://eyn.free.fr/CHOICE.ZIP
--
Z'@+...che et Bonne Année 2006.
C:\DOCUME~1\jp>CHOICE do you like me ? do you like me ? [Y,N]?Y C:\DOCUME~1\jp>;-))
--
Z'@+...che et Bonne Année 2006.
JP : Zen, mes Nuggets ! ;-) La connaissance n'est bonne que si elle est partagée.
- 1
- 2
Suivant
e.g.: timeout /t temp in seconds
e.g.: timeout /t 60
and to not display a message
e.g.: timeout /t 60>nul
if msdos tells you that the command does not exist, try
c:\Windows\System32\timeout /t 60>nul