top of page
Search

Understanding Scheduled Tasks in Windows

  • Jan 21, 2024
  • 2 min read

Updated: Feb 12


When we talk about persistence in Windows, scheduled tasks are one of the most effective and widely used methods. Simply put, a scheduled task is a way to automate the execution of a program or script at a specific time or event—without requiring manual intervention.


Attackers often take advantage of this feature to maintain access to a system, execute malicious payloads, or move laterally across a network.


The Role of At.exe and Schtasks.exe

There are two primary tools for managing scheduled tasks in Windows:


  • At.exe – This was one of the earliest task scheduling tools, commonly used in older Windows versions like XP. It became notorious because tasks created with at.exe originally ran with SYSTEM privileges—allowing low-privileged users to escalate their access. While Microsoft has patched this loophole, attackers still use at.exe in environments where Windows 7 and older systems are present.


Example command to schedule a task with at.exe:

at.exe 22:01:00 c:\temp\malware.exe

This command schedules malware.exe to run at 10:01 PM.


  • Schtasks.exe – This is a more advanced and flexible task scheduling tool, replacing at.exe in modern Windows versions. It allows users to create highly specific task schedules, such as running a program when a user logs in or when a particular event occurs.


Example command using schtasks.exe:

schtasks.exe /create /sc daily /tn MalwareTask /tr c:\temp\malware.exe /st 22:01:00

This command creates a daily task named "MalwareTask" that runs malware.exe at 10:01 PM.


-----------------------------------------------------------------------------------------------------


How Attackers Abuse Scheduled Tasks

Attackers love scheduled tasks because they offer stealth and persistence. Here’s why:

  • Tasks can run in the background without alerting the user.

  • They can be configured to execute at system startup, user login, or on specific system events, making them highly flexible.

  • The ability to schedule tasks on remote systems means attackers can use them to spread malware across a network.


A real-world example of this technique was seen in the SolarWinds supply chain attack. The SUNSPOT malware, used to inject a backdoor into software builds, was executed using a scheduled task set to start at system boot.


-----------------------------------------------------------------------------------------------------


Where Are Scheduled Tasks Stored?

Windows keeps track of scheduled tasks in multiple locations:


  • C:\Windows\Tasks → Stores .job files for each task.

  • C:\Windows\System32\Tasks → Stores XML versions of scheduled tasks (introduced in Windows 7).

  • Task Scheduler Operational Log → A dedicated event log that records task execution and modifications.


If an attacker sets up a malicious scheduled task, forensic investigators can analyze these locations to track their activities.


-----------------------------------------------------------------------------------------------------


Detecting and Analyzing Scheduled Tasks

To investigate scheduled tasks on a system, you can use the following tools:


  1. Autoruns (Sysinternals) – Provides a complete list of scheduled tasks.

  2. Task Scheduler GUI – The built-in Windows tool for viewing and managing tasks.

  3. Event Viewer (Event ID 4698) – Logs the creation of new scheduled tasks.



For live system analysis, you can also use:
schtasks /query /fo LIST /v

OR

schtasks /query /fo TABLE /v

This command lists all scheduled tasks in detail, helping you spot suspicious entries.


-----------------------------------------------------------------------------------------------------



Conclusion

Scheduled tasks are a powerful automation tool in Windows, but they are also a favorite for attackers seeking persistence. Understanding how they work and where to look for signs of abuse is crucial for both system administrators and security professionals.


--------------------------------------Dean-------------------------------------------------

 
 
 

Comments


bottom of page