0

I have a small program that I would like to run automatically. I figure the best way to do this is to add it to the Windows Scheduler. I'd like to be able to run my program once, and in it have it check to see if it is already added in the Scheduler, and if not, add it.

So i need code to:

  • Check Scheduler for a task with the name I give in the code

  • Add my program to Scheduler if it isn't there

Jeff LaFay
  • 12,882
  • 13
  • 71
  • 101

2 Answers2

1

You need to use this TaskScheduler Class - http://msdn.microsoft.com/en-us/library/system.threading.tasks.taskscheduler.aspx

Examples of how to use is here -

  1. http://www.codeguru.com/forum/showthread.php?t=507362
  2. http://www.codeproject.com/Articles/2407/A-New-Task-Scheduler-Class-Library-for-NET
  3. http://www.firatatagun.com/c-windows-task-scheduler-wrapper-classes-c-sharp/2010/04/22/
  4. http://bartdesmet.net/blogs/bart/archive/2008/02/23/calling-the-task-scheduler-in-windows-vista-and-windows-server-2008-from-managed-code.aspx

Here another similar question - Is it possible to use Windows 7 Task scheduler in own application

Community
  • 1
  • 1
Dor Cohen
  • 16,769
  • 23
  • 93
  • 161
  • The linked `TaskScheduler` class refers to the internal .NET task scheduler which is related to threading. This task scheduler has nothing to do with the Windows task scheduler. – Ruud Jan 02 '14 at 11:00
0

An alternative to the scheduler ... http://quartznet.sourceforge.net/

Antony Scott
  • 21,690
  • 12
  • 62
  • 94