Reputation: 3265
I've searched over this website and i know now how to excecute all .exe in a folder, and this is how i can do that (with batch file .bat) :
for /r "." %%a in (*.exe) do start "" "%%~fa"
Is there a way to execute them with a timer (2s for instance) between each .exe file ?
Upvotes: 1
Views: 1596
Reputation: 79982
for /r "." %%a in (*.exe) do start "" "%%~fa"&timeout /t 2 >nul
&
separates commands, >nul directs the timeout
conversation to the bit-bucket so it isn't seen.
Upvotes: 2
Reputation: 2231
2 options to produce a time out in batch are:
timeout /t SEC
where you replace SEC
with the seconds you want it to time. Add the /nobreak
option if you don't want the user to stop the timer by pressing any key. But be careful with this one: it doesn't guarantee a SEC
seconds timer, it only guarentees it will make the system sleep for a timeinterval between SEC
and SEC - 1
secondsping -n S 127.0.0.1 > nul
. As there is 1 second between each ping this will result in a timeout of S-1
secondsSo for 2 seconds you could do:
for /r "." %%a in (*.exe) do (
start "" "%%~fa"
timeout /t 2 /nobreak
REM Or ping -n 3 127.0.0.1 > nul`
)
Upvotes: 2
Reputation: 6302
You can use timeout
command. To wait 2 seconds, just use this between each of the .exe files.
timeout /T 2
Upvotes: 1