Click here to Skip to main content
15,891,372 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi,
Is Possible to Schedule a .Net application from c# code? I need to select Start Time and Time interval from our c# code. Is this possible? Any one help me to do this?
Posted

It really depends on the start point - if your C# code is a long running process or maybe even a service, you could (and should) take a look at hooking Quartz.Net into it - then you can create a 'task/job' and have that use CreateProcess/Process type semantics to start an external exe
 
Share this answer
 
This example shows how to create a task in Windows Task Scheduler.

See Solution 1 in this question Task Scheduler not calling notepad.exe.[^].
 
Share this answer
 
Yes sir this is possible..On timer's tick open windows application from path.
 
Share this answer
 
Comments
vinodhini sekar 13-Oct-14 6:05am    
Can you please send me any example?
vinodhini sekar 13-Oct-14 6:06am    
Here i want to run my application in every 15min or 20mins like that. Is it possible?
[no name] 13-Oct-14 6:28am    
yes dear it is possible..can you please explain in deep what you want to do & which windows application you want to open??
vinodhini sekar 13-Oct-14 6:35am    
For Example i want to move one file from source to designation in every 15mins. Here i have write a code for File Moving. How can i schedule that App to be runned every 15mins?
timer1.Interval = 15 * 60000; //15 min
private void timer1_Tick(object sender, EventArgs e)
{
          System.Diagnostics.Process.Start(@"C:\Windows\System32\Notepad.exe");
}
 
Share this answer
 
v2
Hi vinodhini, I think the best way you can achieve it using windows scheduler. You better write the code in a console application and trigger it from the windows scheduler. It is safe from there.
 
Share this answer
 
Comments
vinodhini sekar 13-Oct-14 6:26am    
I have already done like this method only. But now they want to change the time interval in UI
NaibedyaKar 13-Oct-14 7:03am    
I think it is always better to setup the scheduler on your server/machine where the scheduler will run. If you want to do it from your code then you would like to check the below blog.
http://bartdesmet.net/blogs/bart/archive/2008/02/23/calling-the-task-scheduler-in-windows-vista-and-windows-server-2008-from-managed-code.aspx

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900