How to execute commands in a batch file in timed intervals

In the below example, the batch file is placed into a loop  and executes the “dir” command every 20 seconds. This solution would be best for users who need to execute a command frequently.

:START
REM Execute the MS-DOS dir command ever 20 seconds.
dir
SLEEP 20
GOTO END

Note: In order for the above batch file to run properly you must have the sleep MS-DOS utility on the computer. This utility is not included with any version of MS-DOS or Windows. However, once downloaded will allow your computer to sleep / delay for any specified amount of seconds.

Leave a Reply

You must be logged in to post a comment.