Attach a Task to a Specific Event
Windows Event Viewer allows you to run a task when a specific event occurs. For instance, you could restart a service when an event is logged or display a message to notify you that an error has occurred! Let’s say you want to be notified when shadow copies fail to function. There are instances when automated shadow copies fail due to storage quotas that you may have set long time ago and you may want to know before the system automatically deletes the oldest shadow copy to make room for a new one!
To display a message when a specific event is logged in the event logs, follow the steps below:
- Open Event Viewer and navigate to the log that contains the event you want to associate with a task. For instance, Shadow copies events are found under the System log which contains events logged by Windows system components.
- Right-click the event and select Attach Task To This Event from the Action menu item.
- Walk through the Create Basic Task Wizard to create the new task.
- You can select the action – Display a message, to display a message for failed Shadow copies.
- Type in a title and a message that reminds you of the specific event.
- Before completing the last step you can check the Open the Properties dialog for this task when I click Finish checkbox, so that you can view and modify any missed details.
- Click Finish and the new task will be created and added to your Windows Schedule.
The steps above depict a simple scenario but the same process can be used for more advanced tasks such as, restarting a service when an event with a specific event ID is logged in the Windows event logs. Then you can create a simple batch file using sc stop service_name and sc start service_name, and set the path of the script on the wizard’s Action page.