Task scheduler, terminate started program in windows Task scheduler, terminate started program in windows windows windows

Task scheduler, terminate started program in windows


At the end of your batch file kill the task.

taskkill /im java.exe

java.exe could be whatever process you are planning on killing. You can add multiple lines of tasskill in a batch file to kill multiple processes at a time.

taskkill /im java.exetaskkill /im explorer.exetaskkill /im svhost.exe


"Stop the existing instance" : The Task Scheduler service will stop the instance of the task that is already running, and run the new instance of the task.

that means it will kill the process that the scheduler has launched, cmd.exe in your case, as you told us your program is started from within a batch.

Now, i'm not familiar with java but i guess that stopping your batch will kill the java process that where launched if it is not started as a service.

The scheduler will then run another cmd process and execute your batch once again


Better solution would be fix the java hang. As the process starts every minute then in your java program should have the code to automatically exit if it takes more than a minute to complete the task. Another way would be in the batch file you can kill the process after 1 minute. Use the taskkill /im to kill the process.