I have a program that runs from the cmd prompt that will run continuously as it is outputting text. I can have it output the text to a text file by adding > path\filename.ext
to the end. I want to write a batch file that will write to a text file. It should timestamp the beginning, run for 30 seconds, then timestamp at the end. This is what I have:
@echo off
For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c-%%a-%%b)
For /f "tokens=1-3 delims=/:/ " %%a in ('time /t') do (set mytime=%%a:%%b %%c)
set mytime=%mytime: =%
echo %mydate%_%mytime% > path\results.txt
start runfile.exe --option=alpha path/data.ext >> path\results.txt
timeout /t 30
taskkill /im runfile.exe /f
echo %mydate%_%mytime% >> path\results.txt
There are 2 problems with this, 1) it is not outputting runfile.exe to my text file, and 2) it is not terminating runfile.exe after 30 seconds.