I am writing a backup process.
Step1: User selects 3 times (Tuesday 1am,3am,10am or Everyday 1am,3am,10am)
Step 2: The application should check the time settings and start the backup process automatically.
Is it possible to start the backup process if the application is not running?
if your client/user is using Windows operating system then you can use Windows Task Scheduler to do the job. To schedule the job programmatically see this post and this post
why don't you use Windows Schedule ?
Sure, just use the Windows Task Scheduler. Windows will take care of running your application.
IMO you can use Windows Scheduler, that is the best. and Also do care of TimeZones :P :P
here are the links which may help you.
Task Scheduler
Related
I want to create one Task Scheduler using C# same as Windows Task Scheduler, to run my .bat (batch) file on particular time.
I found this useful link (http://www.codeproject.com/Articles/38553/TaskScheduler)
in this they schedule trigger, and i want to Schedule my .bat file I mean while i am trying to give my batch file path in tags textbox, its just fired trigger, not run my batch file so, i modify that code little bit, and now I am able to run my batch file also,
but, when i close my application triggering also stop, so, is there any way i can triggering or run my batch file even if i close my application, like window task scheduler???
kindly Help me .
Note: its desktop application using C#
You can programmatically schedule tasks in the Windows Task Scheduler by using this .NET wrapper or by calling the windows command line utility schtasks yourself.
It seems you need a windows service to execute your scheduled tasks. Also see Quartz.NET project, that can be used from smallest apps to large scale enterprise systems.
You can programmatically make a task schedule using Windows Task Scheduler
or you can make a background process or a more recommended approach, a thread so your program still runs in the background and still has a small footprint.
Basically, I have an application that runs every 15 minutes. I would like this Console application to remain hidden and not for example minimise/disturb full screen applications.
What would be the best way to accomplish this, it can't be a service though. I'm writing the console application in C#.
Thanks.
To run an application every 15 minutes use a scheduled task. The very simple way to avoid any window being shown is to make this a normal GUI app rather than a console app, but arrange that you do not show any windows in your GUI app.
like david said if you make it a gui program but never load any windows it will run in the background with nothing ever popping up or showing or anything.. another option would be to have your application run continuously and have it do something every 15 minutes...
One option would be to have the scheduled task run as a different user, Network Service maybe, depends on your needs. This will force it to run under the specificed users context and will not show up on other logged in users screens.
You don't need to do anything. A console application is invisible and doesn't interact with other windows. The only way to even know it's there is through Task Manager or something similar.
I have a C# program that I want to run automatically every night without me having to do this,
I believe there is a way of doing this by setting an automated task however im not sure how to do this?
P.S. not sure if this helps but it has a .exe file in its library.
Thanks in advance.
Have a look at Windows Scheduled Tasks, not sure if it's available only on Windows Server or also XP, Vista, 7...
What about registering this as a scheduled task?
Go to Control Panel -> Scheduled tasks.
Here you can easily add your exe as a task and choose when and how often to run your task.
In Windows 7 this is changed somewhat, but you can find it in
Control Panel -> System and Security -> Administrative Tools -> Task Scheduler
You can schedule tasks to run at whatever interval you like. I don't know what version of Windows you are using but here's how to it in Windows XP
You can use "Scheduled Tasks" on windows.
You could also write your application as a "Windows Service". By this, it would run all the time on a machine, without someone creating a scheduled task.
Windows scheduled tasks is the right way.
Look here for more information.
And here for how to do it in Windows 7
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.
I'd suggest using Windows Task Scheduler instead of a service to launch the application. It is designed for this scenario.
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
Simple. Windows Operating System TASK SCHEDULER. Start your application at specific days. Finished.
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.
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
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;
}
}
I've got about 40 lines of .NET code in a console application that read and RSS feed and store information in a database. I need this code to execute every night for as long as the RSS feed exists (indefinitely). Currently, I just launch the console app. from my home computer.
Because I can't trust myself to remember to do this every night, I somehow need to have this code hosted. I'd like to somehow have this app. or code (it could easily be put in an ASP.NET page codebehind and triggered to execute when the page loads) run automatically without me having to run the console app. manually.
Any ideas?
EDIT: I don't want to run this code from my computer; I can't guarantee my computer will not be hibernating or connected to the Internet every night.
EDIT: Right now I'm thinking spawn a background thread using BackgroundWorker in Application_Start of the global.asax, have it download the RSS feed once a day, and Thread.Sleep() the rest of the time.
Although controversial, Jeff Atwood blogged about how they accomplished this for SO using cache expiration. Check it out at https://blog.stackoverflow.com/2008/07/easy-background-tasks-in-aspnet/.
You could use a similar method and schedule the cache to expire at the time you want the process to kick off.
You could use the Windows built-in task scheduler to start the console application.
I would suggest just using the 'at' command instead of getting this small app hosted somewhere.
C:\>at /?
The AT command schedules commands and programs to run on a computer at
a specified time and date. The Schedule service must be running to use
the AT command.
Email your webhost. Some managed hosts will set up a scheduled task for you.
They will likely have different policies regarding how to call a scheduled task (i.e. some may require it to be an aspx page and not an EXE)
Have you looked at Quartz Scheduler for .NET?
Quoth the tagline: Quartz.NET is a full-featured, open source job scheduling system that can be used from smallest apps to large scale enterprise systems.