Home » Windows OS

Windows Task Scheduler

I have found the following article which seems to explain entirely how to work with Windows Task Scheduler:

But I want to be able to work within XP, Vista, and Win7. What I am not sure about is if there is a completely different version of the task scheduler in XP, and it I need different libraries to access it. If so, are there any example wrappers that can work with both schedulers? Help!

4 Answers Found


Answer 2

I think you can use Quartz.Net to replace Windows Task Scheduler

for details, please read:



Answer 3

I wish to use the Windows Task Scheduler, not a different solution, since Windows has that built in so well as a service. But I want to be able to work within XP, Vista, and Win7. What I am not sure about is if there is a completely different version of the task scheduler in XP, and it I need different libraries to access it. If so, are there any example wrappers that can work with both schedulers? Help!


Answer 4

Hi Rerek,


Thank you for your post!

You can consider posting your problem in General Windows Development Issues forum for more efficient responses. Thanks.


Best Regards,


I have configured a Event viewer task on Windows server 2008 to monitor all the scheduled tasks and send me  an alert when ever a scheduled task fails or throws some error. I have already tested it and it is working fine. But the problem comes when i log out of the machine i get an alert for failed scheduled task.When i login and check there are no failed scheduled task and even then i am getting an failed alert. Is this related to any security issues...Please answer...

I have already configured the Event viewer task to run under my account( with whether user is logged in or not option ) with highest privileges.

Thanks in advance.

I have found the following article which seems to explain entirely how to work with Windows Task Scheduler:

But I want to be able to work within XP, Vista, and Win7. What I am not sure about is if there is a completely different version of the task scheduler in XP, and it I need different libraries to access it. If so, are there any example wrappers that can work with both schedulers? Help!

Hello Everyone! I have scheduled about 5 jobs in Windows scheduler on my Windows2003 server. The jobs executed 3 times and stopped after that. It displayed "Could not start" as the status. I tried to execute it manually but in vein.

Does anybody know what has gone wrong here?

Thank you for your help.





I am running Windows 7 and I would like to backup my files on a network drive.  I downloaded syncToy 2.1 and it works fine manually, but now I am trying to schedule it through the task scheduler.  I looked on several forums and was able to input the command to run successfully (running synctoycmd.exe), but when it runs it opens a cmd terminal and then closes it before I can read what it said. I look in the files I told it to back up and nothing has changed, it did not work.

I appended the suffix -R, then I tried -R "documentsbackup" (the backup name in synctoy), but all have the same result.

The history page just says it ran successfully and is not helpful.

Please help! I looked everywhere, no one else seems to have this problem. I don't know what to do, because I can't see the error output. If anyone knows how to fix this or at least get it to where I can read what it says, I would really appreciate it!



I've implemented a custom Task Scheduler in similar way as it appears in Parallel Extensions Samples package.

According to my scheduling algorithm, certain tasks must be canceled before running when some other task fails. Is there any possibility to dispose of a task when queued to the scheduler but before run? Now when I try to dispose such task, I get an exception. Using cancellation mechanism seems to be problematic in specific situation because I do not want to involve application logic in internal scheduling features. Moreover, it seems strange that scheduler should call cancel() then start task then dispose only to get rid of a task.





I am using/learning the Windows Task Scheduler in win32 C++. I am attempting to retrieve a task object (for a task that exists) but it continually fails & returns the error COR_E_FILENOTFOUND 0x80070002 = The task does not exist

What do you think is going wrong? I know this task exists because I create it (& it does what its supposed to do, open an app at specified time).

Maybe the task name I use to retrieve the ITask object is not correct? The status (priority?) of the task I create is == 3 (if that info helps).

The code I use to create a task is exactly the same as the example code from <a href="http://msdn.microsoft.com/en-us/library/aa383624(v=VS.85).aspx">msdn</a>, the task name is "MyTaskSascha".

Is there anything wrong with my code to retrieve an existing task (I believe the task I am trying to retrieve is not considered "Running" but "Scheduled" so that maybe the problem?):

  return 0;


  bool RetrieveTask( std::string taskName )
	// Post: 

	ITaskScheduler *taskSched = NULL;
	ITask      *task   = NULL;
	HRESULT     hr     = S_OK;
	HRESULT     taskStatus = NULL;

	LPCWSTR wTaskName;
	wTaskName = L"MyTestSascha";

	/// Initialise COM library & obtain Task Scheduler object

	hr = CoInitialize( NULL );

	if ( FAILED(hr) )
		printf( "Failed to coinitialise hresult \n" );
		return false;

	hr = CoCreateInstance( CLSID_CTaskScheduler, NULL, CLSCTX_INPROC_SERVER, 
		          IID_ITaskScheduler, (void**) &taskSched );

	if ( FAILED(hr) )
		printf( "Failed to create instance \n" );
		return false;

	/// Obtain task object

	hr = taskSched -> Activate( wTaskName, IID_ITask, (IUnknown**) &task );
	taskSched -> Release();
	std::cout << wTaskName << std::endl;
	printf( "%s \n", wTaskName );

	if ( FAILED(hr) )
		if   ( hr == 0x80070002 ) { std::cout << "The task does not exist \n"; }
		else if ( hr == 0x80000003 ) { std::cout << "The pwszName parameter is not valid \n"; }
		else if ( hr == 0x80070057 ) { std::cout << "A memory allocation failed \n"; }
		else if ( hr == 0x80041313 ) { std::cout << "The task object version is either unsupported or invalid \n"; }
		printf( "Failed retrieving task object %x \n", hr );
		return false;


My question comes from a particular task that I want performed when a program is started. It comes out of the need to stop an add-on once Internet Explorer is started. I don't want to disable the add-on, and in fact it will restart itself when it discovers that it is turned off via the process manager in Windows Task Manager.

Fact is, the program is the "GoogleToolbarUser_32.exe" and is needed to utilize Google's Toolbar. But, the problem lies in that the program hangs and uses one full CPU when IE is first started up. End the process and it restarts without the CPU hungry bug that takes up so much resources.

I know I can wait until Google fixes this problem but I would like to deal with it myself until then. Using Task Scheduler seemed the most logical method to accomplish this task. But I can't seem to find the procedure that would be used to do this, if any. Seems like this would be a common request. Not so much to shut down a problematic program but in other regards. Say to detect when a program starts, to say, start a log or something of the sort.

Thank you in advance and I hope this is easily accomplished.  Jerry


Not sure if this is a bug, but we have a script we use to backup (after export) data from SharePoint sites.

This script is deployed on 2003 server 32bit  and 2008 server 32 bit and works as a scheduled task on both environments.

The same script does not work under task scheduler on server 2008 but does run from file explorer when you double click it.

Where would I submit this?

Thank you



How to enable Task Scheduler service in Windows programmatically?

I write an application that create a scheduled task. I need to determine if the Task Sheduler is enabled or not and if that is disable, enable it.

 second, i want a function in my application is invoked. How can i set the parameter that when application start in its schedule a specific function run?


I have logged in on windows server 2008 r2 thru administrator accpunt

Still I am not able to change the settings of the service task schedular from services.msc.

I want to make sure that On the Log On tab, the local system account is selected, and that theAllow service to interact with desktop check box has a check mark.

I m not able to change anything when I right click and go to properties tab of task scheduler in services.msc 

 Is there anything that might help me to do this...

please help........

waiting for your reply...

when i open it up i get this error 0x8000ffff?
I have a problem using the task scheduler from an application in Vista(RC1). I'm able to get the task scheduler object but when I try to activate the specific task I get 0x80070005 (access violation) the code to where the application fails is included below. Does anyone have any idea why this doesn't work in Vista? (Works just fine on 2000/XP) Also note!This application is complied ti a Control Panel applet (cpl-file) Code extract:       HRESULT hr        = ERROR_SUCCESS;   bool bReturn      = false;   HRESULT phrStatus;   ITask *pITask;   LPCWSTR lpcwszTaskName;    // Initialize the COM library.   ITaskScheduler *pITS;   hr = CoInitialize(NULL);   if (SUCCEEDED(hr))   {      // Get the Task Scheduler object.      hr = CoCreateInstance(CLSID_CTaskScheduler,                       NULL,                       CLSCTX_INPROC_SERVER,                       IID_ITaskScheduler,                       (void **) &pITS);      if (FAILED(hr))      {         AfxMessageBox("Unable to get task scheduler.");         CoUninitialize();         return bReturn;      }   }   else   {      AfxMessageBox("Unable to initialize the COM library");      return bReturn;   }    // Get the Task object.   lpcwszTaskName = L"Hernis WatchDog";   hr = pITS->Activate(lpcwszTaskName,                       IID_ITask,                       (IUnknown**) &pITask);    // Release ITaskScheduler interface.   pITS->Release();     // Could not find task.   if (FAILED(hr))   {      // Some output for debugging purposes.      char szDebug[256];      if (0x80070002 == hr)         sprintf(szDebug, "File not found");      else if (0x80070005 == hr)         sprintf(szDebug, "Access denied.");      else if (E_INVALIDARG == hr)         sprintf(szDebug, "The pwszName parameter is not valid.");      else if (E_OUTOFMEMORY == hr)         sprintf(szDebug, "A memory allocation failed.");      else if (SCHED_E_UNKNOWN_OBJECT_VERSION == hr)         sprintf(szDebug, "The task object version is either unsupported or invalid.");      else          sprintf(szDebug, "Error = 0x%x", hr);       AfxMessageBox(szDebug);      CoUninitialize();      return bReturn;   }// Rest of code will not get executed since we cannot get an task object.    

Win7/64 bit machine, SyncToy 2.1 worked fine, then stopped running correctly in Task Scheduler.  If I run on command line, it reports "has not been syncronized".  Was working fine then quit.  Manual run syncs fine.

Any suggestions?   Thanks


I am syncing 21GB of data between my primary hard drive and a second hard drive on the same computer.

The computer is; AMD Phenom IIX4 965, 4 GB RAM Win7 64bit, two 500GB hard drives

If I use synctoy.exe or launch synctoycmd.exe in a cmd window, the process will complete in less than one minute.  If I launch synctoycmd in Task Scheduler, which I prefer to run it unattended, the process takes 20 to 50 minutes.

My command line is C:/Program Files/synctoy 2.1/synctoycmd.exe -R"Craig Backup"

I have disabled saving files to the Recycle Bin and I eliminated files from the process that don't copy like *.dat; *.log* etc

Any ideas on how to speed the process up when launching from Task Scheduler?  Or why this process should be any slower than manually launching the process in a command window?




I have a  hundred tasks, lets say with indices 1..100. Tasks 50 to 75 are more CPU intensive than 1-50, and tasks 76-100 are the most CPU intensive.

When using Parallel-For with degree of parallelism set to 10 and the default Task Scheduler, eventually, there are only 3 threads (or 2) doing the work, when all 10 worker threads should be executing (right?). I assume the default task scheduler allocates tasks 1 to 10 to the first thread, 11-20 to second and so on and thus worker Threads 9 and 10 get to do the most work.

How can I remedy this? Is there a built-in scheduler that I could use for this type of tasks? I am going thru the extension samples, but it will take some time for me to understand them fully.

Thanks in advance.


I have a simple console application that has this in mainline: 

Console.WriteLine(System.String.Format("the current directory is: {0}", System.IO.Directory.GetCurrentDirectory()));


File.WriteAllText(@"test.txt", "new contents");  


I compile this in VS 2010 and copy the EXE to a directory named "c:\test".  When I run this code in two different OS's via "Task Scheduler" and "Scheduled Task" I get different results.  

In Windows Server 2003 R2 "Scheduled Task" this code will create a file as I would expect, c:\test\test.txt with the proper contents written to it. 

When I run this same code on Windows 2008 R2 (64 bit version) "Task Scheduler" it writes the expected contents to an unexpected location, c:\C:\Windows\SysWOW64\test.txt.

In both environments if I run the exe's from a command line, it writes to c:\test\test.txt as I would expect.

As I understand it, if you don't fully qualify the file name in the first parameter of the WriteAllText method it will write the contents to the file in the directory of the executable however this seems to break down when running in the Windows 2008 Task Scheduler.  I know I can fully qualify the file name or put the expected path in a XML somewhere with the location of where to write the file but this breaks down a convention that I use.  Any ideas why this behavior does what it does?



i'm using TaskScheduler.dll to use scheduling functionality in my app. i don't have problem with win 7, but in win xp, the task doesn't run.

for more info plz see my sample project which run calc.exe in your scheduled time.

can anybody help me to work-around the problem ?

thanks in advance



I want to create a task scheduler programatically which runs repeatetly every 15 mins.How to achieve this?In windows 7,i navigate to task scheduler and tried to create a task.In the create task pop up,i navigate to trigger tab where in the create trigger pop i can see the option Repeat task every and duration.So i can create a repeated trigger which will run indefinetly.

I want to achieve this programatically.Which trigger class i have to use? can anyone help me in this? Thanks in advance.








I am running Win Server 2008 R2.  I have a console app that I wrote, which runs just fine when I click on ConsoleApp1.application file.  I want the task scheduler to run this console app every ten minutes, so I set up a task using task scheduler.  Whenever the task scheduler tries to run it, though, it fails, and return an erro rmessage "%1 is not a valid Win32 application. (0x800700C1)".

Most of what I've found in searching talks about making this stuff work on IIS, but I'm not using IIS.  I'm just running a pretty plain ol' vanilla console app.

This is a console app, not a web app.  I've set the task up as a Windows 2008 R2 task, using Domain Administrator credentials, with "Run with highest privileges" checked.  I'm not sure what else to do.  Can someone provide some other advice to try?


I am using Windows SBS 2008 SP2. I found some strange problem occur on the task scheduler services.

I configured the shadow copies & windows backup task on my server, set the triggers run everyday. It work fine from Monday to Saturday.

But on Sunday, it suddenly bypass all of the tasks means no task has been run whole day. There is no error message on the event viewer about both tasks. So I restart the server, it work fine again.

Next Sunday, the strange problem occur again, no tasks has been run UNTIL I restart the server.

I checked the event log, noticed that the task eng did not start to request the task to launch, why ?

What is the problem of the task scheduler ? Why the task has not been run without any error log on event viewer ?

I don't want to restart the server everyweek to make it work. Please help to fix it.


<< Previous      Next >>

Microsoft   |   Windows   |   Visual Studio   |   Sharepoint   |   Azure