This post first appeared on the ET Ducky blog. I build ET Ducky, an RMM that reads ETW on Windows and eBPF on Linux.

Event ID 200 from the Microsoft-Windows-TaskScheduler source records each action a scheduled task launched. Microsoft lists its message as follows, where %1 is the task, %2 is the action, and %3 is the instance.

Task Scheduler launched the "%2" action in the "%3" instance of task "%1". 

Microsoft's guidance for the event on its own is "This is a normal condition. No further action is required." The events appear on the "History" tab of each task in Task Scheduler. They can also be read with Get-WinEvent.

What it means

One event 200 is written for each action a task runs. When a program you removed keeps coming back, or your antivirus blocks the same file again every day, look for an event 200 at the minute it started. The task named in that event is the one still launching the program.

How to find the cause

  1. Open Task Scheduler and check the "Action" pane. Task history can be enabled or disabled there. Select "Enable All Tasks History" if that is the option shown.
  2. Note the time of the next start or block, from your antivirus's detection history or the program's own log.
  3. List the task events from the hour before the block. Run it within an hour of the block, or change AddHours(-1) to reach back further.
Get-WinEvent -FilterHashtable @{ ProviderName='Microsoft-Windows-TaskScheduler'; Id=129,200,201; StartTime=(Get-Date).AddHours(-1) } | Select-Object TimeCreated,Id,Message 
  1. Find the event 200 at the minute of the block. Event 129 from the same task instance records the process ID it launched, which you can match to the running process.
  2. Export the task's definition as XML and keep the output before you change anything. Pass the task's folder as -TaskPath with a leading and trailing backslash. '\' is the root folder.
Export-ScheduledTask -TaskName 'Name from the event' -TaskPath '\' 
  1. Find out who created the task. Security event 4698, "A scheduled task was created", records the account that created it and the task's XML in its "Task Content" field. It belongs to the "Audit Other Object Access Events" audit subcategory.
Get-WinEvent -FilterHashtable @{ LogName='Security'; Id=4698 } -MaxEvents 20 | Select-Object TimeCreated,Message 

Fixes

Disable the task first, so it can't launch the program again while you check it.

Disable-ScheduledTask -TaskName 'Name from the event' -TaskPath '\' 

Remove the task once you know nothing you need depends on it. Unregister-ScheduledTask asks for confirmation before it removes the task.

Unregister-ScheduledTask -TaskName 'Name from the event' -TaskPath '\' 

Check the root folder of the Task Scheduler Library for other tasks you don't recognize. Microsoft notes that scheduled tasks created manually or by malware are often located in the root node.

Get-ScheduledTask -TaskPath '\' | Select-Object TaskName,State 

Turn on auditing for the "Audit Other Object Access Events" subcategory on the PCs where this matters, so event 4698 records the next task that is created.

Related events

  • Event ID 100, "Task Scheduler started the "%3" instance of the "%1" task for user "%2"."
  • Event ID 129, "Task Scheduler launched the "%2" instance of the "%1" task with process ID %3."
  • Event ID 201, "Task Scheduler successfully completed task "%1" , instance "%3" , and action "%2"."
  • Event ID 202, "Task Scheduler failed to complete the "%2" instance of the "%1" task with action "%3". The error value is: %4."
  • Event ID 203, "Task Scheduler failed to launch action "%3" in instance "%2" of task "%1". The error value is: %4."
  • Security event ID 4698, "A scheduled task was created."

Where ET Ducky shows it

I build ET Ducky. Its agent reads process creation events from the kernel, so a program a scheduled task starts shows up in the event stream with its parent. Beyond the fifteen built-in behavioral rules, you can create custom rules using a rule builder to monitor for events that are unique in your environment. Automations can be configured around the alerts those rules raise.

One Windows or Linux server costs $5 a month with no query subscription. Pricing is at https://etducky.com/pricing.

Sources