Task launch failed, instance already running

2

1

I am trying to launch a task from task scheduler. The task is executing a batch file. It is running for the first time but after that it's status is not getting changed from Running to Ready. It is running at an interval of 1 hour for 12 hours. I have tried creating the task from scratch, but could not solve it. I cannot go for the hotfix solution also. Kindly suggest me some other ways out.

Note: The solution is not getting any kind of exceptions as well, because it would have been logged in the log files.

Please help. Thanks in advance.

Rajdeep Nandi

Posted 2016-07-28T09:27:05.623

Reputation: 33

Answers

2

It can happen that a task that runs as scheduled task simply does not terminate. Whether this is a fault of task manager or the script is unknown, but both can be at fault here. For example, if the batch file contains a pause statement, the batchfile expects a keypress to continue. The task scheduler will never send it, and this the script never finishes.

That being said, I've seen occasions where a task finishes normally, yet task scheduler does not recognize this to be the case. The script terminates normally, yet task manager claims its still running.

For this reason, Microsoft enabled the option to terminate a task after x hours if its still running.

So what you want to do is edit the task, go to the settings tab and find the Stop the task if it runs longer than 3 days and change this to 1 hour.

At the bottom, you will find: If the task is already running, the following applies: Do not start a new intstance.

Change this to Run a new instance in parallel.

Notice that this option has the ability to kill the previous task or queue. I deliberately choose not to utilize this method.

Now, once you save the settings, right click the task and choose stop to stop the running instance.

Keep in mind, if the script really is at fault here, it may be the case that it does not run normally and thus whatever it is supposed to do never is being done. For example, if you run your script without task scheduler and it works, and does some stuff on network shares, and now you configure to do this with task scheduler, but you run it with higher privileges, it may simply not have access to the network shares and fails for that reason. That should however terminate the script normally though.

LPChip

Posted 2016-07-28T09:27:05.623

Reputation: 42 190

But will it start a new instance again after 1 hour @LPChip ? – Rajdeep Nandi – 2016-07-28T10:17:38.317

It will if your triggers are set up to do so. – LPChip – 2016-07-28T10:30:43.640

Hi @LPChip , your solution worked perfectly for me...but could you please tell if there will be any impact on the application later on? – Rajdeep Nandi – 2016-07-29T06:01:02.240

I'm sorry, but this is a question I can't impossibly answer as I know nothing about the application. Using task scheduler to run a script will always impact the system very little, but if its going to be a problem, I can't tell. – LPChip – 2016-07-29T12:02:28.200