DosTips.com

A Forum all about DOS Batch
It is currently 25 Aug 2016 07:05

All times are UTC-06:00




Post new topic  Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Time limit on executable
PostPosted: 19 Jul 2012 09:09 
Offline

Joined: 19 Jul 2012 08:30
Posts: 2
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!


Top
   
PostPosted: 19 Jul 2012 09:19 
Offline
Expert

Joined: 23 Dec 2011 13:59
Posts: 3165
So use TASKLIST to see if it is still running. If it isn't then run the next step.


Top
   
PostPosted: 19 Jul 2012 09:31 
Offline

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


Top
   
PostPosted: 19 Jul 2012 10:39 
Offline
Expert

Joined: 10 Feb 2012 02:20
Posts: 5895
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.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 4 posts ] 

All times are UTC-06:00


Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Yahoo [Bot] and 20 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® Forum Software © phpBB Limited