How to Trigger Tasks from System Events in Windows 11
Automating tasks in Windows 11 based on specific system occurrences is an effective way to maintain system health, run backups, or trigger custom scripts. By combining the diagnostic logging of the Windows Event Viewer with the automation engine of Task Scheduler, you can instruct your computer to execute a program or script the exact moment a specific Event ID or source log is registered. This guide provides a straightforward, step-by-step walkthrough to identify target system events and configure custom scheduled tasks triggered by those events.
Step 1: Identify the Target Event Details
Before creating your scheduled task, you need the specific identifier for the event you want to use as a trigger.
- Press Win + R, type
eventvwr.msc, and press Enter to open the Event Viewer. - In the left sidebar, expand Windows Logs and select the category relevant to your trigger (such as System, Application, or Security).
- Locate the event you want to use as a trigger and click on it.
- Note the following three details from the event summary:
- Log Name (e.g., System)
- Source (e.g., Kernel-Power, Disk, or Service Control Manager)
- Event ID (e.g., 1074 for a system shutdown/restart)
Step 2: Create a Custom Task in Task Scheduler
Using the full “Create Task” wizard allows you to fine-tune permissions, triggers, and actions.
- Press Win + R, type
taskschd.msc, and press Enter to open Task Scheduler. - In the right-hand Actions pane, click Create Task….
General Tab
- Enter a Name and optional Description for your task.
- Under Security options, choose whether the task should run only when the user is logged on or whether it should run regardless of login status.
- Check Run with highest privileges if your action requires administrator rights.
Triggers Tab
- Click the Triggers tab, then click New….
- Open the Begin the task drop-down menu and select On an event.
- Choose the Basic setting and specify the event
details identified in Step 1:
- Log: Select the corresponding log (e.g., System).
- Source: Select the exact source name from the list.
- Event ID: Type the numerical Event ID.
- (Optional) For advanced scenarios involving specific event data, switch the radio button to Custom and click New Event Filter… to build complex XML queries.
- Click OK.
Actions Tab
- Click the Actions tab, then click New….
- Set Action to Start a program.
- In the Program/script field, click
Browse… to select your executable, batch file
(
.bat), or script (.ps1).- If running a PowerShell script, enter
powershell.exein the program box, and add-ExecutionPolicy Bypass -File "C:\Path\To\YourScript.ps1"into the Add arguments box.
- If running a PowerShell script, enter
- Click OK.
Conditions and Settings Tabs
- Review the Conditions tab to configure network and power restrictions (e.g., uncheck Start the task only if the computer is on AC power for laptops).
- Review the Settings tab to dictate how the task behaves if it fails or runs longer than expected.
- Click OK to save the task. Enter your Windows user credentials if prompted.
Step 3: Verify and Test the Task
- In Task Scheduler, select Task Scheduler Library from the left pane and find your newly created task in the central list.
- In the right-hand pane, click Enable All Tasks History to ensure future executions are logged.
- Simulate or wait for the system event to occur.
- Refresh Task Scheduler and check the Last Run Result column or the History tab at the bottom to confirm that your event successfully triggered the task.