View unanswered posts | View active topics It is currently 01 Sep 2014 05:09



Post new topic Reply to topic  [ 4 posts ] 
Time limit on executable 
Author Message

Joined: 19 Jul 2012 08:30
Posts: 2
Post Time limit on executable
I am looking to incorporate a time limit function on an executable that I am running multiple times from a batch file.

I know that I can use the "ping localhost" command to delay for a set amount of time and then "taskkill" to terminate my executable if it is still running after the delay.

However, my problem is this: Some times the executable may take only a few minutes, sometimes it will take a few hours (with 24hrs being the cut-off I wish to set). If I set the batch file to delay 24hrs before trying to kill the executable and the executable finishes after only a few minutes, the next run of the executable will not start until 24hrs have passed. I want the next run to start immediately after the previous one finishes.

As an additional note, changing the source code of the executable is not really an option for me, as it is developed by a third party and they would most likely decline to incorporate my changes.

Thanks!


19 Jul 2012 09:09
Profile

Joined: 23 Dec 2011 13:59
Posts: 1802
Post Re: Time limit on executable
So use TASKLIST to see if it is still running. If it isn't then run the next step.


19 Jul 2012 09:19
Profile

Joined: 19 Jul 2012 08:30
Posts: 2
Post Re: Time limit on executable
How would I go about using TASKLIST simultaneously with the ping command?
And then how would I halt the ping command?


19 Jul 2012 09:31
Profile

Joined: 10 Feb 2012 02:20
Posts: 4114
Post Re: Time limit on executable
You'd have to create a file with a timestamp each time the program starts, and delete the file after the program has run.

A second batch file is needed to check the timestamp (if exist file check timestamp) every 2 minutes and if it reaches 24 hours then kill the task.


19 Jul 2012 10:39
Profile
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 


Who is online

Users browsing this forum: Yahoo [Bot] and 11 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Forum style by Vjacheslav Trushkin for Free Forums/DivisionCore.