How to add a Scheduled Task to the Task Scheduler
-
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. -
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.You need to use ITaskScheduler interface. You can easily come to know how to use it, and there are related interfaces.
-
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.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