Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

1) In your start runfile.xe parms line, try to use start "" runfile.exe parms

2) When you start runfile.exe, what is the image name? When you start task manager, is it still called "runfile.exe" or does it change to something else?

I have a program that uses a launcher. The launcher is called "runme.exe" (this is just an example) which in turn preps other programs for a program called "programname.exe" If I wanted to kill that task, I would have to kill "programname.exe" as that is the program that remains in memory after "runme.exe" finishes executing. Check and see if your program does something similar.

Hope this helps.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.