DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Interface with W2K Task Scheduler (mstask.dll)???

  1. #1
    Scott Guest

    Interface with W2K Task Scheduler (mstask.dll)???


    I'm trying to schedule tasks on a web server from an ASP page using the Task
    Schdeuler mstask.dll COM object.

    I can't figure out how to interface with it from VB or ASP. There is an SDK
    on the MSDN site but it only has C++ examples. I can't even reference the
    dll from within VB.

    Any help would be greatly appreciated.

    Scott



  2. #2
    HappyGG Guest

    Re: Interface with W2K Task Scheduler (mstask.dll)???


    I was looking for the same stuff and I found this at this address:
    http://www.microsoft.com/msj/default...297/newnav.htm

    "The New Task Scheduling Interfaces

    One of the first things I noticed about Windows NT 5.0 is that it added the
    ability to schedule tasks. If you've used the CRON utility with Unix, you're
    familiar with the concept. To the user, this feature is seen as the Scheduled
    Tasks application. This program is invoked via the Start menu, under Programs
    | Admin-istrative Tools | Scheduled Tasks. There's even a Scheduled Tasks
    Wizard to guide the user through creating a new task.
    A task can be run once at a particular time, or can be set up to execute
    on a repeating basis. Scheduled tasks can even be used to start programs
    on other machines. Imagine the ability to automatically reboot the boss's
    computer 10 minutes before the weekly status meeting. Of course, it wouldn't
    really be this easy, since scheduled tasks are subject to all the standard
    Windows NT security requirements.
    The Scheduled Tasks capability is built atop standard operating system functionality.
    A program called MS-TASK.EXE runs at startup, and is responsible for firing
    off tasks at the appropriate time. The properties of each individual task
    are stored in a file with the .JOB extension that MSTASK reads. All the .JOB
    files are kept in a common directory. The location of the .JOB directory
    can be found in the registry value: HKEY_LOCAL_MACHINE\ SOFTWARE\Microsoft\SchedulingAgent\TasksFolder.
    Of course, we programmers always want programmatic access to system goodies
    like this, and Windows NT doesn't disappoint. A new header file, MSTASK.H,
    provides the definition for these new COM interfaces:
    ITaskScheduler
    ITask
    ITaskTrigger
    IScheduledWorkItem
    IEnumWorkItems
    IProvideTaskPage
    The ITaskScheduler interface is the most fundamental of the Task Scheduler
    interfaces. ITaskScheduler lets you add, delete, change, and enumerate tasks,
    as well as administer tasks on other machines. Obtaining an ITask-Scheduler
    instance is easy. Simply call CoCreate-Instance, specifying CLSID_CTaskScheduler
    as the CLSID and IID_ITask--Scheduler as the IID. Here are the ITask-Scheduler
    interfaces.
    SetTargetComputer / GetTargetComputer
    Enum
    Activate
    Delete
    NewWorkItem / AddWorkItem
    IsOfType
    The next important interface to understand is ITask. ITask is what you use
    to control a task object. You can set and retrieve all of the task's information,
    execute and terminate the task, add and delete triggers, and allow the user
    to modify the task via a property page. I'll get to trig-gers momentarily.
    If you dig through the definition of the ITask interface, you won't find
    methods that do all the various things that I mentioned above. It turns out
    that ITask is derived from the IScheduledWorkItem interface. I've listed
    the methods of this interface in Figure 9. For the most part, they're self-explanatory.
    Here are the additional methods that the ITask interface adds to the IScheduledWorkItem
    interface.
    SetApplicationName / GetApplicationName
    SetParameters / GetParameters
    SetWorkingDirectory / GetWorkingDirectory
    SetPriority / GetPriority
    SetTaskFlags / GetTaskFlags
    SetMaxRunTime / GetMaxRunTime
    You determine when a task should run with a task trigger. A trigger is a
    set of criteria that, when met, causes a task to be run. There are two types
    of triggers: time-based and event-based. The ITaskTrigger interface is how
    you create and modify triggers. The IScheduledWorkItem interface contains
    the CreateTrigger method, which returns a pointer to an ITaskTrigger interface.
    There are additional methods to modify and delete an existing ITaskTrigger.
    Time-based triggers activate at a specified point in time. Not only can you
    set the time that they become active, you can also have them activate once,
    daily, weekly, monthly, or on a specified day of the month. Event-based triggers
    activate in response to certain system events, like when the system starts
    up, when a user logs on, or when the system goes into an idle state.
    The last interface of the task scheduling group is IProvide-TaskPage. It
    allows you to display three property pages that allow the user to alter the
    behavior of a task. To show some of the TaskScheduler interfaces in action,
    I wrote the ScheduledTasks sample program shown in Figure 10. It just goes
    through the motions of creating the various required interface instances,
    and pops up the system-supplied UI that lets you edit a task's properties."


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center