create a program to run another sheduled program

  • Thread starter Thread starter Eranga
  • Start date Start date
E

Eranga

Hello All,
I need to run one program from another within time slots specified by
the user. Could some one please tell me how this could be achieved?
The program that should be run is created in C#, I would prefer to make
the other one also in C# please help me with this!!1
Thanks in advance
 
check out the windows 'Task Scheduler Service' it is free and installed on
all XP machines I believe.
It can be access from the Start Menu -> All Programs -> System Tools ->
Scheduled Tasks.

You can configure it to run your C# program periodically.

HTH

Ollie Riches
 
Thanks for this idea.I checked it.
But my program's start time and time slot is not fixed through a GUI the
user can change it. So if I use windows sheduled tasks facility I won't
be able to adoptive? Isn't this so?
Also could you please tell me how can I can configure it to run the C#
program periodically?
 
you use the wizard in the menu, it allows to specify a date\time and allows
the user to change it

Ollie Riches
 
hi
i think that you have to use the "Process" class from your program to run
the second one.
you have to use also a timer to run it periodically.
you can find the "Process" class under the "System.Diagnostics" namespace.
hope this will help
El-Sayed Mohamed
 
Hi,


Here is a piece of code that does that, I use the config file to store the
app path, args and interval

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
private void Form1_Load(object sender, System.EventArgs e)

{

//setup the timer

int interval = Convert.ToInt32(
System.Configuration.ConfigurationSettings.AppSettings["Interval"]) *

1000 *

(
System.Configuration.ConfigurationSettings.AppSettings["MinutesORSeconds"].ToLower()=="m"?60:1
);

this.timer1.Interval = interval;

this.timer1.Tick+=new EventHandler(timer1_Tick);

timer1.Enabled = true;

timer1_Tick( null, null);


}



private void timer1_Tick(object sender, EventArgs e)

{

timer1.Stop();

//Restart the process

ProcessStartInfo si = new ProcessStartInfo();

si.FileName =
System.Configuration.ConfigurationSettings.AppSettings["path_to_exe"] ;

si.WindowStyle = ProcessWindowStyle.Hidden;

//Set the other parameter

if ( this.currentIndex == this.list.Count )

currentIndex = 0;

si.Arguments =
System.Configuration.ConfigurationSettings.AppSettings["args_to_exe"]+ " " +
list[currentIndex].ToString();

currentIndex++;



theRunningProcess = Process.Start( si );

timer1.Start();

}
 
Back
Top