Task Scheduler Did Not Launch Task "\Abc" Because Instance "(Guid)" of the Same Task Is Already Running

I am scratching my head for the last 2 days because of this issue. This error is intermittent on the production server as sometimes the task scheduler works and sometimes not.

The same settings work in the development server.

I also checked the execution policy on both servers and it looks the same.

4

4 Answers

In your second screenshot, you can choose "Stop existing instance" in the latest dropdown list (if the task is already running). Then the retry option might trigger your task again correctly.

I had almost this exact problem where running a command line app from command line would work, but not when running it as scheduled task.

It turned out the scheduled task is quite sensitive on the fact that parameters must be passed as parameters and not be part of the target .exe.

So if there is anyone other struggling with this kind of problem, make sure you have your command line parameters as parameters (see the picture attached).

Also if you like to make your scheduled task using PowerShell scriptin you can do this like:

$action = New-ScheduledTaskAction -Execute "c:\temp\myApp.exe" -Parameters "testConnection true" -WorkingDirectory "c:\tempFiles\"

Do yourself a favor and save your hair on your head! Just set all task scheduler jobs as follows, and you'll never have issues with these ridiculous "warnings".

Don't tick anything else. The design of this program was poorly tested IMO.

Solution that work for me
Inject IHostApplicationLifetime

public class CoreHostService : IHostedService
{
  private readonly IHostApplicationLifetime _hostApplicationLifetime;
  CoreHostService(IHostApplicationLifetime hostApplicationLifetime)
  {
     _hostApplicationLifetime = hostApplicationLifetime;
  }

  public async Task StartAsync(CancellationToken cancellationToken)
  {
     ...
     //do something
     ...
     _hostApplicationLifetime.StopApplication();
   }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Marcus Vance

Marcus Vance

Cybersecurity & Digital Privacy Researcher

Marcus Vance is a cybersecurity auditor and technology writer dedicated to educating the public about online safety, data privacy regulations, enterprise security, and emerging cyber threats.

Share this article
Twitter Facebook Pinterest