0

I am trying to attach a task (B) to run after the completion of another task (A), which I got to work using windows built in feature by right clicking an event and attaching a task to it. However, task B keeps running repeatedly after successfully completing its own task and never stops. The trigger to run task B is upon task A's log with event 102 (also tried 201 and it didn't help).

I've tried to find an option to stop after completing the task once (which is how I think it should be by default), but can't find anything. I haven't been able to find any relevant posts to this problem, only posts referring to their task not running.

For testing, I'm making task A run a batch file to download a file using WinSCP scripting then task B runs a batch file that runs a python script to create a file. I am using windows 10 home edition if it matters.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992

1 Answers1

0

The problem was that the trigger for task B wasn't triggering for only task A's 102 event code, but for any 102 event code (including its own), so it kept running the task over and over. I used these sources to create task B manually 1 2. When I first tried to create the tasks manually, the task I wanted to run was in a sub-directory, but I didn't include the directory in the task name, so it didn't work. If you want to find the directory your task is in, then you have to go to the events properties, details, then xml view. From there scroll to the bottom and use the path given from the <Data Name="TaskName"> field.

<QueryList>
  <Query Id="0" Path="Microsoft-Windows-TaskScheduler/Operational">
    <Select Path="Microsoft-Windows-TaskScheduler/Operational">*[EventData [@Name='TaskSuccessEvent'][Data[@Name='TaskName']='\Sub-directory\taskA']]</Select>
  </Query>
</QueryList>