Search code examples
batch-filecmdscheduled-tasks

How to execute a .bat to run multiple files in a timed sequence?


I am wanting to write a simple batch file. It will pick up a file from a directory, let's say D:\scripts\script1.conf, and let's it run. I then want there to be a 60 second delay, and have the same batch file pick up D:\scripts\script2.conf, and so on.

How would it be possible to achieve this?


Solution

  • start "" "D:\scripts\script1.conf"
    timeout /t 60 /nobreak > NUL
    start "" "D:\scripts\script2.conf"
    timeout /t 60 /nobreak > NUL
    

    So this will run one file, wait for 60 seconds, and run the second.
    start will open the file by its type-linked-program.
    The first parameter "" specify the window title it started -- If the program can be titled.

    You can incorporate these with for and goto to loop through some files or other conditions.