views:

224

answers:

2

Hi, I've created a setup file in winforms application. After installing that setup file i want to run that file at a specific time in a day only.

Ex : every day 12 PM that program automatically popups

how can i do it? any idea?

+4  A: 

Add an entry to the Windows task scheduler would be the easiest way.

I've never done this, but it should be possible to do during setup. (Even if that would mean executing some additional code during setup.) Problem is the difference in task schedulers before and after Vista. There is a Task Scheduler API and Vista and better also have a special commandline application to create new jobs.

Workshop Alex
yes this is what exactly i needed. but that should happen automatically through setup file only. is it possible?
Nagu
Added 3 additional links to answer. Unfortunately, I have no further experience with the scheduler. I do have some experience with writing your own scheduler service and believe me, you **don't** want to do that!
Workshop Alex
@Workshop Alex - Do you have a web page or blog post about the issues you ran into? I've been supporting a database driven service for scheduling program execution for years and haven't run into any "Problems". Lack of planning, dependencies etc, but not really any real problems.
Brad Bruce
Unfortunately, no blog yet. But the problem in general is that you would need to create a service that runs 24/7 which only has to wait until it's time to trigger the event. Making sure it doesn't eat too many CPU cycles is a real challenge! And the Task Scheduler is a much simpler solution.
Workshop Alex
+2  A: 

You can call "C:\WINDOWS\system32\at.exe" to schedule programs to run. Watch out for the program overlapping the next run as well.

Please don't do this:-

"Add a timer to windows service that will check every 3 minutes for example if it is the time to execute" If you must that use an interval timer, at least do the maths and calculate the interval so windows can swap the damn thing out.

Dunno about you but I've got a million little tray apps that wake up every 30 seconds just to check if they're supposed to be running as it is. No more of them thanks.

JonB