Basic class for using the Microsoft Task Scheduler | CodeGuru

Basic class for using the Microsoft Task Scheduler

Microsoft developed a full-featured scheduler for IE 4, IE 5, Win 98, and NT 5. From looking at all the task options available (three property pages, plus an "advanced" dialog) you could imagine that programming the scheduler is quite a chore. And you’d be right. I developed the CScheduledTask class to help you create very […]

Written By
CodeGuru Staff
CodeGuru Staff
Apr 24, 1999
1 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

Microsoft developed a full-featured scheduler for IE 4, IE 5, Win 98, and NT 5. From looking at all the task
options available (three property pages, plus an "advanced" dialog) you could imagine that programming
the scheduler is quite a chore. And you’d be right. I developed the CScheduledTask class to help you create very
simple tasks and understand the basics of using the scheduler.

[Sample scheduled task - 5K]


  • Fixed some compile errors when building for Unicode. Thanks to Chris Maunder for providing the fixes!
  • Fixed SaveTask() to properly check for an existing task. The change was necessary because I worked around a
    bug in IE 4, but the bug was fixed in IE 5, resulting in my code breaking when run on IE 5.
  • Added a #pragma to automatically link with mstask.lib, so you don’t have to remember to do that in
    your app’s project settings.
  • Added a check after the CoCreateInstance() call to see if the error is REGDB_E_CLASSNOTREG. If so, I display
    a nicer trace message explaining that you don’t have the scheduler installed.

Demo project


Take the link below to download a demo project that illustrates using the CScheduledTask class.

Download demo project – 33KB

Download source – 9K

Date Last Updated: April 24, 1999

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.