locked
Create a scheduled task from an aplication in c# RRS feed

  • Question

  • Hi.
    I need to know if there is a way to create a programmed task from an aplication in c#.
    Thanks for yours comments.
    Friday, May 9, 2008 7:45 AM

Answers

  •  

    It is supported from C#, it's a COM interface.  Add a reference to the TaskScheduler type library like I wrote above, and you'll be able to work with it from C# like any other COM object.
    Friday, May 9, 2008 5:23 PM

All replies

  • What is a programmed task?

     

    Friday, May 9, 2008 7:49 AM
  • What exactly is a "programmed task" ?
    Friday, May 9, 2008 7:49 AM
  • Ok, I did not use the right name..

    Change it for "scheduled task"

     

    Thanks..

    Friday, May 9, 2008 8:10 AM
  • Take a look at the Task Scheduler API: http://msdn.microsoft.com/en-us/library/aa383614.aspx

     

    On Vista the API has been extended in several areas, but it's still a COM API.  So you need to add a reference to the TaskScheduler type library and use the types from there - they are very .NET friendly.  You'll find several examples under the link above.

    Friday, May 9, 2008 9:06 AM
  • Thank you for your reply. I found this API, but there is a restriction (I believe). The documentation said the following:

     

    Developer Audience

    The Task Scheduler provides APIs for the following developers:

    • Task Scheduler 1.0: Interfaces are provided for C++ development.
    • Task Scheduler 2.0: Interfaces and objects are provided for C++ and scripting development respectively.

     

    It means that there are not way to do that in C# ??

    Friday, May 9, 2008 10:49 AM
  •  

    It is supported from C#, it's a COM interface.  Add a reference to the TaskScheduler type library like I wrote above, and you'll be able to work with it from C# like any other COM object.
    Friday, May 9, 2008 5:23 PM
  • Thank you Sasha.

    I found a very simple way to reach the objective (to create a scheduled task, using a c# application).

    It isn´t a "elegant" way, but in my case, is the best solution (implementation time, easily, etc)

    In your application, you can create a .bat file with the next command line inside:

    at 14:15 /interactive notepad.exe

    Then, you execute your .bat from you application, and a new task will be created at the time that you specified.

     

    Is only a way, but the "at" command have a lot of options..

    See you..

     

    Tuesday, May 13, 2008 8:25 AM
  • Instead of using code, you can do it using 'SCHTASKS' command, run it using System.Diagnostic.Process.Start method with the parameters required. It's easy and not much effort required.

    Tuesday, June 1, 2010 12:34 PM
  • I have created one C# application which can able to create a programmed task using Task Scheduler. But the problem is the task scheduler pops up a black (console like) "taskeng.exe" window. The window comes in front of all other windows. Is there a way to avoid this window and running in background

    Thursday, April 21, 2011 9:48 AM
  • You can try using the library at http://taskscheduler.codeplex.com/ as it wraps the COM interfaces and allows for simpler interactions from C# or VB.NET. It also automatically switches between the 1.0 and 2.0 COM interfaces depending on which OS version you are using.
    • Proposed as answer by dahmaninator Thursday, June 23, 2011 6:40 AM
    Sunday, April 24, 2011 5:02 AM