Re-run the same .EXE program after previous finished

0

I have this PaymentAPI.exe program that need to be run, then rest for 5 minutes, then continue new run instance. It is crucial that not more than 1 instance should be running at same time. The running duration may depends on network connectivity and data within.

For example it may run for 5 minutes or 30 minutes. However no matter how long it runs, when it completed, it will wait for 5 minutes then run again. How do I setup such setting in Task Scheduler? Thank you.

4 Leave Cover

Posted 2018-11-10T19:07:56.223

Reputation: 113

Task Scheduler isn't suitable for this. It'll just run apps at a fixed period – phuclv – 2018-11-11T03:15:23.050

Answers

-1

Use a batch script (.bat) like this:

:loop
PaymentAPI.exe
timeout 300
goto loop

It loops forever, waiting 300 seconds between launches.

Edit: This ultra-simple script is being downvoted, apparently because of lack of understanding of what it does.

It is based on the fact that a script launching a program is paused as long as that program is executing. To execute in parallel and not cause the script to pause, the program must be launched by the Start command, not by simple invocation, and will then open a new window of its own (either graphical or console). This is what the above script is based on, to achieve exactly what is demanded by the poster.

harrymc

Posted 2018-11-10T19:07:56.223

Reputation: 306 093

@Albin: Both are extensions are equivalent. I added an explanation. – harrymc – 2018-11-10T22:18:16.770

cmd is the preferred suffix for Win2K and up, in addition bat and cmd are not equivalent – Albin – 2018-11-10T22:41:02.137

By using this script, the program is always open and will not close? Or will it close when the previous instance completed and re-open on next instance? – 4 Leave Cover – 2018-11-11T04:50:16.017

@4LeaveCover: The loop is: Program starts, works as long as it takes, stops, timeout waits 300 seconds, loop restarts. – harrymc – 2018-11-11T08:08:59.063

You need to add /nobreak to the timeout command otherwise if the user presses any key the batch file will not wait 300s. – DavidPostill – 2018-11-11T08:48:25.450

1bat and cmd are not the same – DavidPostill – 2018-11-11T08:51:40.003

1@DavidPostill: The small cmd/bat differences are meaningless in the context of the post. /nobreak is also meaningless in the context of the Task Scheduler, specified in the post. – harrymc – 2018-11-11T10:26:36.273

Com'on guys, stop downvoting a working solution because of cosmetic reasons. Downvotes are for answers that don't solve the problem, not for one word that you don't agree with in the answer or comments. Such downvotes only serve to frighten the poster away from a real solution to his problem. – harrymc – 2018-11-11T10:29:36.170