Skip to content

Codepolice

  • ⤫

Send E-Mail When a task in Task Scheduler Fails

Posted by Judy Alvarez Posted on February 28, 2022March 1, 2022
0

You would guess that this would be a really easy task but it turns out this was pretty complicated. Basically, you need to create a scheduled task that gets triggered by an event and do some editing of that task in a notepad. I will just post my exported task here. Feel free to use it / modify it as you want.
<?xml version=”1.0″ encoding=”UTF-16″?>
<Task version=”1.2″ xmlns=”http://schemas.microsoft.com/windows/2004/02/mit/task”>
<RegistrationInfo>
<Date>2012-09-07T09:36:00.5466938</Date>
<Author>Administrator</Author>
</RegistrationInfo>
<Triggers>
<EventTrigger>
<Enabled>true</Enabled>
<Subscription>&lt;QueryList&gt;&lt;Query Id=”0″ Path=”Microsoft-Windows-TaskScheduler/Operational”&gt;&lt;Select Path=”Microsoft-Windows-TaskScheduler/Operational”&gt;*[System[(EventID=201)]] and *[EventData[(Data[@Name=”ResultCode”]!=0)]]&lt;/Select&gt;&lt;/Query&gt;&lt;/QueryList&gt;</Subscription>
<ValueQueries>
<Value name=”custom”>Event/EventData/Data[@Name=’TaskName’]</Value>
<Value name=”eventChannel”>Event/System/Channel</Value>
<Value name=”eventRecordID”>Event/System/EventRecordID</Value>
<Value name=”eventSeverity”>Event/System/Level</Value>
</ValueQueries>
</EventTrigger>
</Triggers>
<Principals>
<Principal id=”Author”>
<UserId>Administrator</UserId>
<LogonType>Password</LogonType>
<RunLevel>LeastPrivilege</RunLevel>
</Principal>
</Principals>
<Settings>
<MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
<DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>
<StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
<AllowHardTerminate>true</AllowHardTerminate>
<StartWhenAvailable>false</StartWhenAvailable>
<RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
<IdleSettings>
<StopOnIdleEnd>true</StopOnIdleEnd>
<RestartOnIdle>false</RestartOnIdle>
</IdleSettings>
<AllowStartOnDemand>true</AllowStartOnDemand>
<Enabled>true</Enabled>
<Hidden>false</Hidden>
<RunOnlyIfIdle>false</RunOnlyIfIdle>
<WakeToRun>false</WakeToRun>
<ExecutionTimeLimit>P3D</ExecutionTimeLimit>
<Priority>7</Priority>
</Settings>
<Actions Context=”Author”>
<SendEmail>
<Server>localhost</Server>
<Subject>Event $(eventRecordID) – $(custom) – $(eventChannel)</Subject>
<To>[email protected]</To>
<From>[email protected]</From>
<Body>Yo!</Body>
<HeaderFields />
<Attachments />
</SendEmail>
</Actions>
</Task>
Just save it as an XML file and import it into the Task Scheduler.

Categories: JavascriptTagged: asp dot net interview questions, asp dot net tutorial, asp net core 3, asp net core health check, asp net core vs php, asp net developer job, asp net development companies, asp net ecommerce website, asp net events, asp net for beginners, asp net interview questions and answers for 5 years experience, asp net microsoft, asp net middleware, asp net mvc là gì, asp net mvc projects, asp net page life cycle events, asp net pdf generator, asp net programming language, asp net service, asp net web app, c# asp net tutorial, client side validation in asp net, data controls in asp net, entry point of asp net core application, hire asp net developer india, html server controls in asp net, html to pdf asp net, net asp, regular expression validator in asp net, treeview control in asp net

Post navigation

Previous Previous post: Run Dropbox As a Windows Service on Windows Server 
Next Next post: Using log4net to Send Mail With SmtpAppender In a Console Application

Related Posts

  • Package efficiency and dependency hygiene

    #​752 — September 12, 2025 Read on the Web If you have any interest in music and being able to render music or generate music with JavaScript, be sure to check out the very end of this issue where we’ve dedicated an entire section to the topic 🙂__Your editor, Peter Cooper JavaScript Weekly How to Keep

    Posted by Posted on September 12, 2025
    0
  • A significant supply chain attack on the npm ecosystem

    #​592 — September 9, 2025 Read on the Web A Major Supply Chain Attack Hits the npm Ecosystem — In July, Socket warned us about a phishing campaign targeting npm package publishers. Sadly, a prolific package author (among others, like DuckDB, who explain how the attack worked on them) fell victim to the scam, resulting

    Posted by Posted on September 9, 2025
    0
  • Why browsers throttle JavaScript timers (and what to do about it)

    #​751 — September 5, 2025 Read on the Web JavaScript Weekly Mediabunny: A Complete Media Toolkit for JavaScript — Supporting both browsers and Node.js, this library lets you read, write and convert popular media file formats (e.g. MP4, MP3, and more) without needing to lean on dependencies like FFmpeg. You can make thumbnails, extract metadata,

    Posted by Posted on September 5, 2025
    0
  • The latest on Oracle’s hold on JavaScript

    #​750 — August 29, 2025 Read on the Web JavaScript Weekly An Illustrated Guide to Big O and Time Complexity — A fantastic JavaScript-oriented, interactive, visual essay about Big O notation and its role in describing algorithmic complexity. This is a beautiful bit of work, even if you’re already wise to O(log n) and O(n^2).

    Posted by Posted on August 29, 2025
    0
  • The productivity benefits from type stripping

    #​591 — August 26, 2025 Read on the Web How We Migrated Our Rush.js Monorepo to Node Type Stripping — Since v23.6 (and in LTS since v22.18.0), Node has supported running (most) TypeScript code by stripping the types out first. The Calm team was excited about the potential for improving productivity and DX, and set

    Posted by Posted on August 26, 2025
    0
  • We still love jQuery

    #​749 — August 22, 2025 Read on the Web ☀️ We’re back after a week off, though I’m starting to think we should have taken two weeks off as it’s been quite quiet in JavaScript-land this August! Nevertheless, we still have a full issue for you today, so let’s get on to it.. 😉__Peter Cooper, your

    Posted by Posted on August 22, 2025
    0
Judy Alvarez

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Codepolice

  • Github
  • Atlassian
  • Flatlogic
  • Xero
  • Jetbrains
  • Figma
  • Package efficiency and dependency hygiene
  • A significant supply chain attack on the npm ecosystem
  • Why browsers throttle JavaScript timers (and what to do about it)
  • The latest on Oracle’s hold on JavaScript
  • The productivity benefits from type stripping
https://flatlogic.com/generator
COPYRIGHT © 2025 - Codepolice