shanthiram
shanthiram

Reputation: 219

Way to execute a .Net application on specific days

I have a requirement where an application which is run by windows service to be executed on specific days in a week(Sunday through Saturday). These days should be stored in a config file and can be changed by user at any time.

Can you please point to right direction in achieving this. Please let me know if you need any clarification on this.

Upvotes: 1

Views: 185

Answers (6)

Fernando
Fernando

Reputation: 137

I agree with all the above. Windows Task Scheduler would be the best and easiest solution.

You could even write a console application and set it to run at given times.
Here is a small guide to console applications for scheduled tasks:
http://www.15seconds.com/issue/080508.htm

Upvotes: 1

Icemanind
Icemanind

Reputation: 48736

As everyone has answered, Windows Scheduler is already part of Windows and will do this for you. However, if you need a programmatic answer to this, you can use the following C# code:

// Read in your configuration file
// and I am assuming you are reading in the file and storing the
// Days of the week you need it to run in a string array
foreach (string DayToRun in MyStringArray)
{
    if (DateTime.Now.DayOfWeek.ToString().ToUpper().Equals(DayToRun.ToUpper())
    {
        // Today is the day we need to execute. 
        // Do execution here
        System.Diagnostics.Process.Start("C:\\MyProgramToExecute.EXE");

        break;
    }
}

Upvotes: 0

the_drow
the_drow

Reputation: 19201

How about registering them to the scheduled tasks?
It already has a great interface and any user can deal with them, let alone your costumer's IT depeartment.
You can also create a tool that registers the scheduled task to windows with parameters according to the XML file.

Upvotes: 3

Reed Copsey
Reed Copsey

Reputation: 564931

I'd suggest using Windows Task Scheduler instead of a service to launch the application. It is designed for this scenario.

Upvotes: 12

TomTom
TomTom

Reputation: 62159

Simple. Windows Operating System TASK SCHEDULER. Start your application at specific days. Finished.

Upvotes: 3

del.ave
del.ave

Reputation: 1948

If You are in Windows environment, then you can use Windows Task Scheduler.

The following is for Windows XP, but the instructions are almost the same for other versions of Windows

http://support.microsoft.com/kb/308569

Upvotes: 5

Related Questions