Looping Batch Script Recipe

  1. Create a file named diagscript.bat with contents based on the following. Add your desired commands between the echo ... Iteration and the timeout lines.
    @echo off
    SETLOCAL ENABLEDELAYEDEXPANSION
    
    :loop
    
    echo [%date% %time%] Iteration
    
    timeout /t 30 > NUL
    
    goto loop
  2. Open a command prompt and change directory to where you would like to store the script output:
    cd C:\
  3. Execute the script and redirect output to a file:
    C:\diagscript.bat > diagstdlogs.txt 2>&1
  4. When you are ready to stop the script, kill it by typing Ctrl^C in the command prompt window.
  5. Upload diagstdlogs.txt and any other relevant logs.