In a batch process which calls an executable, you may need to prevent this executable from being launched more than once if the batch is restarted.
It is then interesting to wait for the end of the process or to cancel the call.
The function below, to be included in the calling Batch, allows you to check if a process is not running and, if so, to wait X seconds before restarting the check.
It takes 3 parameters as input:
This example checks every 20 seconds that the Windows calculator is not displayed, as in the screenshot below:
This other example checks every 5 seconds that the Java program "program.jar" is not running: