Forensic ArtifactWindows: Execution

Scheduled Tasks (XML Files)

Scheduled task definitions stored as XML files record task name, triggers, actions (executable path + arguments), run-as context, and creation timestamps.

Scheduled Tasks are one of the most frequently abused persistence mechanisms in real-world intrusions. Every scheduled task on a Windows system is defined by an XML file stored in C:\Windows\System32\Tasks\, and these files contain the exact executable path, command-line arguments, triggers, run-as context, and creation timestamps that investigators need to identify malicious persistence — even after the attacker has deleted the task from the Task Scheduler interface.

What Are Scheduled Tasks?

The Windows Task Scheduler (schtasks.exe / taskschd.msc) allows users and administrators to schedule programs, scripts, and commands to run automatically at specified times, intervals, or in response to system events. Each task is defined by an XML document stored on disk at C:\Windows\System32\Tasks\. The Task Scheduler service (Schedule) reads these XML files and executes the defined actions according to the configured triggers.

From an attacker’s perspective, scheduled tasks are an ideal persistence mechanism: they survive reboots, run with configurable privilege levels (including SYSTEM), can be triggered by logon events or boot sequences, and can be named to resemble legitimate Windows maintenance tasks. The MITRE ATT&CK framework documents this as T1053.005 — Scheduled Task, one of the most commonly observed persistence techniques in enterprise intrusions.

The XML task definition files are the primary forensic artifact because they contain the complete task configuration at rest. Even if an attacker creates and then deletes a scheduled task, the XML file may be recoverable from the $MFT, Volume Shadow Copies, or file system slack space.

Registry vs. XML

In addition to the XML files in System32\Tasks\, scheduled task metadata is also stored in the registry at HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\. The TaskCache\Tree subkey contains the task hierarchy, and TaskCache\Tasks\{GUID} contains binary data including the last-run time, last-result code, and a hash of the task definition. Both artifacts should be collected. The registry entries may persist after the XML file is deleted.

Location & Format

ComponentPathDescription
Task XML filesC:\Windows\System32\Tasks\One XML file per task; subfolder hierarchy mirrors task folder structure
Task XML (legacy)C:\Windows\Tasks\Legacy .job files (Windows XP/2003); binary format, not XML
TaskCache registryHKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Binary task metadata: GUID, last run time, result code, triggers
Task Scheduler logMicrosoft-Windows-TaskScheduler/Operational.evtxEvent IDs 106 (created), 140 (updated), 141 (deleted), 100 (started), 102 (completed)

XML Structure

Each task XML file conforms to the http://schemas.microsoft.com/windows/2004/02/mit/task namespace. The critical elements for forensic analysis are:

XML / TASK DEFINITION
<?xml version="1.0" encoding="UTF-16"?>
<Task xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
  <RegistrationInfo>
    <Date>2026-03-15T02:14:00</Date>            <!-- Task creation timestamp -->
    <Author>NT AUTHORITY\SYSTEM</Author>       <!-- Account that created the task -->
    <Description>System maintenance</Description>
  </RegistrationInfo>
  <Triggers>
    <LogonTrigger>                             <!-- Runs at user logon -->
      <Enabled>true</Enabled>
    </LogonTrigger>
  </Triggers>
  <Principals>
    <Principal>
      <UserId>S-1-5-18</UserId>               <!-- SYSTEM SID -->
      <RunLevel>HighestAvailable</RunLevel> <!-- Elevated privileges -->
    </Principal>
  </Principals>
  <Actions>
    <Exec>
      <Command>C:\ProgramData\svchost.exe</Command>    <!-- SUSPICIOUS: svchost outside System32 -->
      <Arguments>-enc aQBlAHgA...</Arguments>      <!-- Base64-encoded PowerShell -->
    </Exec>
  </Actions>
</Task>
Red Flag Indicators

The XML above shows the three most common indicators of a malicious scheduled task: (1) an executable path outside C:\Windows\System32\ despite mimicking a system binary name (svchost.exe in ProgramData), (2) Base64-encoded arguments suggesting obfuscated PowerShell, and (3) creation as SYSTEM at 02:14 AM — outside business hours. Legitimate Windows tasks have well-documented names, use expected binary paths, and are created during OS installation or patch cycles.

What It Reveals

Scheduled task XML files answer the following investigative questions:

Forensic Use Cases

1. Malware Persistence via Legitimate-Looking Task Names

An attacker creates a scheduled task named MicrosoftEdgeUpdateTaskMachineUA — nearly identical to the legitimate MicrosoftEdgeUpdateTaskMachineCore. The XML file shows the <Command> element pointing to C:\Users\Public\Documents\edge_update.exe instead of the legitimate C:\Program Files (x86)\Microsoft\EdgeUpdate\MicrosoftEdgeUpdate.exe. The creation timestamp in <RegistrationInfo><Date> is 2026-03-15T02:14:00, three days after the initial compromise confirmed by other artifacts. The trigger is LogonTrigger with RunLevel set to HighestAvailable.

2. Ransomware Pre-Encryption Staging

Ransomware operators commonly use scheduled tasks to execute the encryption payload across multiple machines simultaneously. A scheduled task named WindowsSecurityHealthCheck is found on 47 domain-joined workstations, all with identical XML definitions. The <Command> points to \\DC01\SYSVOL\contoso.local\scripts\health.exe (a UNC path on the domain controller’s SYSVOL share), and the <TimeTrigger> is set to 2026-03-20T03:00:00 — the planned encryption time. The task was created by CONTOSO\svc-admin, a compromised service account.

3. Data Exfiltration on a Schedule

An insider creates a scheduled task that runs a PowerShell script every 4 hours to compress and upload files from a specific directory to a personal cloud storage account. The XML shows <Command>powershell.exe</Command> with <Arguments>-ExecutionPolicy Bypass -File C:\Users\jdoe\Documents\sync.ps1</Arguments>. The <CalendarTrigger> specifies a <Repetition> interval of PT4H (4 hours). The task was created under the user’s own account, not SYSTEM, which is typical for insider threat scenarios.

4. Lateral Movement via Remote Task Creation

Attackers with administrative credentials on a target machine can create scheduled tasks remotely using schtasks /create /s TARGET_HOST or via the Task Scheduler COM API over RPC. The resulting XML file on the target machine contains the task definition, but the <Author> field may show the source account. Event ID 106 in the Task Scheduler Operational log on the target confirms the creation event. Cross-referencing the creation timestamp with network logon events (Event ID 4624 Type 3) on the target identifies the source machine.

5. Cobalt Strike Beacon Persistence

Cobalt Strike’s built-in persistence module creates scheduled tasks via the schtasks command. Common patterns include tasks running rundll32.exe with a DLL in %APPDATA% or %TEMP%, or tasks executing powershell.exe with a Base64-encoded download cradle in the <Arguments> field. The creation timestamp often correlates with the Beacon’s initial check-in time visible in firewall or proxy logs.

Detection Heuristics

The following heuristics help distinguish malicious scheduled tasks from the hundreds of legitimate tasks present on a typical Windows system:

IndicatorSuspicious PatternLegitimate Pattern
Executable pathC:\ProgramData\, C:\Users\Public\, %TEMP%, %APPDATA%C:\Windows\System32\, C:\Program Files\
Binary nameSystem binary name in non-system directory (svchost.exe in ProgramData)Expected binary in expected path
Arguments-enc (encoded PowerShell), URLs, IP addresses, Base64 stringsKnown switch combinations for the application
Creation timeOutside business hours; correlates with known compromise timelineDuring OS install, patch Tuesday, or admin maintenance windows
AuthorService account, SYSTEM, or account not expected to create tasksMicrosoft Corporation, known admin accounts
Task nameNear-miss of legitimate names (MicrosoftEdgeUpdateTaskMachineUA)Exact match to documented Microsoft task names
Hidden flag<Hidden>true</Hidden>Most legitimate tasks are not hidden
Trigger typeBootTrigger or LogonTrigger for non-system binarySpecific CalendarTrigger schedules for maintenance tasks
Quick Triage Command

On a live system, the following command exports all scheduled task XML definitions for offline analysis. Compare each <Command> path against a known-good baseline:

CMD / ADMIN
:: Export all task definitions to a single directory for review
schtasks /query /xml ONE > C:\Evidence\all_tasks.xml

:: Or query individual tasks with full XML output
schtasks /query /tn "MicrosoftEdgeUpdateTaskMachineUA" /xml

:: List all tasks with their next run time, status, and author
schtasks /query /fo CSV /v > C:\Evidence\tasks_verbose.csv

Acquisition Methods

Collection Warning

Task XML files in C:\Windows\System32\Tasks\ are readable by administrators but the directory permissions may restrict non-admin access. On a live system, run collection commands from an elevated prompt. Also collect the TaskCache registry keys and the Task Scheduler Operational event log for complete context.

Live System — Direct Copy

CMD / ADMIN
:: Copy all task XML files preserving directory structure
robocopy "C:\Windows\System32\Tasks" "C:\Evidence\ScheduledTasks" /COPYALL /E /ZB

:: Export TaskCache registry hive
reg export "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache" C:\Evidence\TaskCache.reg

:: Copy Task Scheduler event log
copy "C:\Windows\System32\winevt\Logs\Microsoft-Windows-TaskScheduler%4Operational.evtx" C:\Evidence\

Live System — KAPE Collection

CMD / ADMIN
:: KAPE target for Scheduled Tasks
kape.exe --tsource C: --tdest C:\Evidence\KAPE_Output --target ScheduledTasks

:: Velociraptor VQL for task enumeration
:: SELECT * FROM glob(globs="C:/Windows/System32/Tasks/**")
:: Or use artifact: Windows.System.TaskScheduler

Forensic Image — Direct Extraction

BASH / FORENSICS
# Mount forensic image read-only
mount -o ro,noexec,nodev /dev/sdb1 /mnt/evidence

# Copy all task XML files
cp -r /mnt/evidence/Windows/System32/Tasks/ /analysis/scheduled_tasks/

# Also extract the SOFTWARE hive for TaskCache registry data
cp /mnt/evidence/Windows/System32/config/SOFTWARE /analysis/scheduled_tasks/

# Extract Task Scheduler event log
cp /mnt/evidence/Windows/System32/winevt/Logs/Microsoft-Windows-TaskScheduler*.evtx /analysis/scheduled_tasks/

Parsing Tools & Analysis

ToolAuthorLicenseOutputNotes
schtasks /queryMicrosoft (built-in)Built-inXML / CSV / TableLive system only; native Windows command; /xml flag for full definition
AutorunsMark Russinovich (Sysinternals)FreeGUI + CSVShows scheduled tasks alongside other persistence mechanisms; VirusTotal integration
AutorunscSysinternalsFreeCSVCLI version of Autoruns; scriptable for remote collection
Python xml.etreePython stdlibOpen sourceScriptedParse task XML files programmatically for bulk analysis
KAPE + TaskParserKrollFreeCSVAutomated collection and parsing pipeline for scheduled tasks
VelociraptorRapid7Open sourceJSON / CSVWindows.System.TaskScheduler artifact for remote collection

Bulk Analysis Script — Suspicious Task Finder

PYTHON / ANALYSIS
import os, xml.etree.ElementTree as ET

ns = {'t': 'http://schemas.microsoft.com/windows/2004/02/mit/task'}
suspicious_paths = ['ProgramData', 'Users\\Public', 'AppData', 'Temp', '%TEMP%']

task_dir = '/analysis/scheduled_tasks/Tasks'

for root, dirs, files in os.walk(task_dir):
    for f in files:
        path = os.path.join(root, f)
        try:
            tree = ET.parse(path)
            r = tree.getroot()

            # Extract key fields
            cmd = r.find('.//t:Actions/t:Exec/t:Command', ns)
            args = r.find('.//t:Actions/t:Exec/t:Arguments', ns)
            date = r.find('.//t:RegistrationInfo/t:Date', ns)
            author = r.find('.//t:RegistrationInfo/t:Author', ns)
            hidden = r.find('.//t:Settings/t:Hidden', ns)

            cmd_text = cmd.text if cmd is not None else 'N/A'
            args_text = args.text if args is not None else ''

            # Check for suspicious indicators
            flags = []
            if any(p.lower() in cmd_text.lower() for p in suspicious_paths):
                flags.append('SUS_PATH')
            if '-enc' in args_text.lower() or 'encodedcommand' in args_text.lower():
                flags.append('ENCODED_PS')
            if hidden is not None and hidden.text == 'true':
                flags.append('HIDDEN')

            if flags:
                print(f'[{"!".join(flags)}] {f}')
                print(f'  Command:  {cmd_text}')
                print(f'  Args:     {args_text[:80]}')
                print(f'  Created:  {date.text if date is not None else "N/A"}')
                print(f'  Author:   {author.text if author is not None else "N/A"}')
                print()
        except ET.ParseError:
            print(f'[PARSE_ERROR] {path}')

Sample Output

OUTPUT
[SUS_PATH!ENCODED_PS!HIDDEN] MicrosoftEdgeUpdateTaskMachineUA
  Command:  C:\ProgramData\svchost.exe
  Args:     -enc aQBlAHgAIAAoAE4AZQB3AC0ATwBiAGoAZQBjAHQAIABOAGUAdAAuAFcA...
  Created:  2026-03-15T02:14:00
  Author:   NT AUTHORITY\SYSTEM

[SUS_PATH] WindowsSecurityHealthCheck
  Command:  C:\Users\Public\Documents\health.exe
  Args:     --silent --config C:\Users\Public\Documents\cfg.dat
  Created:  2026-03-14T23:47:00
  Author:   CONTOSO\svc-admin

Retention & Persistence

PropertyBehavior
LifespanTask XML files persist on disk until explicitly deleted via schtasks /delete, Task Scheduler GUI, or manual file removal
Survives rebootYes — this is the primary purpose of scheduled tasks as a persistence mechanism
Survives OS upgradeGenerally yes; in-place upgrades preserve System32\Tasks\
TaskCache after XML deletionRegistry entries in TaskCache may persist after the XML file is deleted; the task will not run but metadata remains
Event log retentionTask Scheduler Operational log: default size 1 MB; events roll over on active systems; increase via wevtutil sl
$MFT recoveryDeleted task XML files may be recoverable from $MFT resident data or via file carving if the file was small enough
Volume Shadow CopyPrevious versions of task XML files are captured in VSS snapshots, allowing recovery of deleted or modified tasks
Deleted Task Recovery

When an attacker creates a scheduled task, uses it, then deletes it, the XML file may still be recoverable. For small XML files (typically under 700 bytes for simple tasks), the entire file content may be resident in the $MFT record and recoverable even after deletion. Additionally, the TaskCache registry entries persist independently of the XML file. Event ID 141 in the Task Scheduler Operational log records task deletion events with the task name.

Anti-Forensics Resilience

Scheduled task XML files are moderately resilient to anti-forensics activity. They are not targeted by consumer cleanup tools, but sophisticated attackers who understand the persistence mechanism will delete the task after use.

Tool / ActionClears Task XML?Clears TaskCache?Clears Event Log?
CCleanerNoNoNo
BleachBitNoNoNo
schtasks /deleteYes — removes XML filePartially — some entries may remainNo — Event ID 141 logged
Manual XML file deletionYes — but $MFT may retain contentNo — TaskCache entries persistNo
wevtutil cl (clear event log)NoNoYes — but Event ID 1102 logged in Security.evtx
TimestompingCan modify $STANDARD_INFORMATION but not $FILENAME timestampsRegistry last-write time harder to modifyEvent log timestamps are hardened
Defense in Depth

The three independent evidence sources for scheduled tasks — XML files on disk, TaskCache registry entries, and Task Scheduler event log entries — must all be individually destroyed for complete anti-forensics success. Most attackers delete the task via schtasks /delete, which removes the XML and some TaskCache entries, but leaves Event ID 141 in the operational log and may leave residual TaskCache data. This layered evidence model is the reason all three sources should be collected during incident response.

MITRE ATT&CK Detection Mapping

Scheduled task artifacts provide evidentiary support for detecting the following MITRE ATT&CK techniques:

TechniqueNameScheduled Task Evidence
T1053.005 T1053.005Scheduled TaskPrimary technique; task XML defines the persistence mechanism, executable, triggers, and run-as context
T1059 T1059Command and Scripting Interpreter<Command>powershell.exe</Command> or cmd.exe with encoded/obfuscated <Arguments>
T1547 T1547Boot or Logon Autostart ExecutionTasks with BootTrigger or LogonTrigger achieve the same effect as Run key persistence
T1036 T1036MasqueradingTask names mimicking legitimate Windows tasks; system binary names in non-system directories
T1021 T1021Remote ServicesRemote task creation via schtasks /create /s indicates lateral movement
T1070 T1070Indicator RemovalTask deletion (Event ID 141) after use is itself evidence of cleanup activity

Related Artifacts & Cross-References

Corroborating Artifacts

ArtifactRelationship to Scheduled TasksCross-Correlation Value
Security.evtx (4688)Process creation events triggered by the task4688 events with parent process svchost.exe -k netsvcs -p -s Schedule confirm task-initiated execution
Task Scheduler Operational.evtxEvent IDs 106/140/141/100/102Complete task lifecycle: creation, modification, deletion, start, completion
PrefetchExecution evidence for the binary specified in <Command>Prefetch confirms the executable ran; scheduled task XML explains why/when it ran
$MFTFile creation timestamps for the task XML and the executed binary$MFT timestamps for the task XML should match the <Date> element in the XML content
SRUM.dbNetwork usage by the executed binaryIf the task executed a network-active binary, SRUM captures transfer volumes
Amcache / ShimCacheExecution history for the binary specified in <Command>Amcache SHA-1 hash confirms the exact binary version that was executed
Registry Run KeysAlternative persistence mechanismAttackers often deploy multiple persistence mechanisms; check both scheduled tasks and Run keys

References

  1. MITRE ATT&CK, “T1053.005 — Scheduled Task” — https://attack.mitre.org/techniques/T1053/005/
  2. Microsoft, “Task Scheduler Schema” — https://learn.microsoft.com
  3. Mark Russinovich, “Autoruns for Windows” — https://learn.microsoft.com/en-us/sysinternals/downloads/autoruns
  4. SANS Institute, “Scheduled Task Forensics” — https://www.sans.org/blog/
  5. 13Cubed, “Windows Scheduled Tasks Forensics” — https://www.13cubed.com/blog
  6. Red Canary, “Threat Detection Report — Scheduled Tasks” — https://redcanary.com
  7. Microsoft, “Task Scheduler Events” — https://learn.microsoft.com

Mjolnir Security — Digital Forensics & Incident Response

Mjolnir Security provides 24/7 incident response, digital forensics, and expert witness testimony. Our DFIR team specializes in persistence mechanism analysis, scheduled task forensics, and enterprise-wide threat hunting for malicious autostart entries.

Digital ForensicsIncident ResponseExpert WitnessArtifact AnalysisPersistence HuntingMalware Analysis

mjolnirsecurity.com — 24/7: +1 833 403 5875