Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Task scheduler, terminate started program in windows

At my work we have a set up with the task scheduler periodically starting a java program to read mails. the task is scheduled to run every minute and it calls a .bat file which starts the java program.

Now the problem. Once in a month or so the jave.exe process doesn't end properly, so the next minute when it tries to run I get:

Task Scheduler failed to start "\XXX Jobs" task for user "NT AUTHORITY\System". Additional Data: Error Value: 2147750687.

And then I get that message every minute until I terminate the java.exe from the task manager.

Now my question, in task scheduler there are some options to choose. Under settings there is "If the task is already running, then the following rule applies" If I then choose "Stop the existing instance" Will this stop the java.exe or just the task? Or is there a better way.

Some advice would be welcome.

like image 928
Johannes Avatar asked Apr 07 '14 12:04

Johannes


People also ask

How do you make a scheduled task to start stop a service?

Open Task Scheduler (Start > in search type Task Scheduler and select when found). Once Task Scheduler opens, in the right column window click on Create Task... In the General tab, type a name for the service. Enable the "Run whether user is logged on or not" and "Run with highest privileges".

How do I make task Manager stop automatically?

Get to the Applications or Processes tab by pressing Ctrl + Tab to switch between tabs. Press Tab to move down to the program or processes list, and then use the arrow keys to highlight the program you want to End task. Once highlighted, press Alt + E to End task the program.


1 Answers

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.exe
taskkill /im explorer.exe
taskkill /im svhost.exe
like image 95
Andrew Avatar answered Nov 05 '22 12:11

Andrew