Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to add a Scheduled Task to the Task Scheduler

How to add a Scheduled Task to the Task Scheduler

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestioncareer
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    PravinSingh
    wrote on last edited by
    #1

    I want to write a program that makes a particular exe run everyday. For this, it should add that exe to Scheduled Tasks. But how to do that programatically? All I know is, when we add a new Scheduled Task, say MyTask, it creates a file "C:\Windows\Tasks\MyTask.job", but this file contains some binary data and can't be directly created/editad. Any Standard Ways / Workarounds ?


    It's better to know some of the questions than all of the answers.
    Pravin.

    P D 2 Replies Last reply
    0
    • P PravinSingh

      I want to write a program that makes a particular exe run everyday. For this, it should add that exe to Scheduled Tasks. But how to do that programatically? All I know is, when we add a new Scheduled Task, say MyTask, it creates a file "C:\Windows\Tasks\MyTask.job", but this file contains some binary data and can't be directly created/editad. Any Standard Ways / Workarounds ?


      It's better to know some of the questions than all of the answers.
      Pravin.

      P Offline
      P Offline
      prasad_som
      wrote on last edited by
      #2

      You need to use ITaskScheduler interface. You can easily come to know how to use it, and there are related interfaces.

      1 Reply Last reply
      0
      • P PravinSingh

        I want to write a program that makes a particular exe run everyday. For this, it should add that exe to Scheduled Tasks. But how to do that programatically? All I know is, when we add a new Scheduled Task, say MyTask, it creates a file "C:\Windows\Tasks\MyTask.job", but this file contains some binary data and can't be directly created/editad. Any Standard Ways / Workarounds ?


        It's better to know some of the questions than all of the answers.
        Pravin.

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        Here's a starting point:

        HRESULT hr = CoInitialize(NULL);
        if (SUCCEEDED(hr))
        {
        ITaskScheduler *pITaskScheduler = NULL;

        hr = CoCreateInstance(CLSID\_CTaskScheduler, NULL, CLSCTX\_INPROC\_SERVER, IID\_ITaskScheduler, (void \*\*) &pITaskScheduler);
        if (SUCCEEDED(hr))
        {
            ...
            pITaskScheduler->Release();
        }
        
        CoUninitialize();
        

        }

        See here for more.


        "One must learn from the bite of the fire to leave it alone." - Native American Proverb

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups