5

I have a small C# program that I created that contacts a web service and retrieves and processes datasets. No problem with that after some head scratching and much exploring of stackOverflow - thanks to all who contribute.

I normally work in the Linux world, so this is a rare foray into the Windows Environment. What I need to do is set it up so that TaskScheduler will run this application. There is no console display or interaction, everything is written to log files.

In Linux I would simply use a CRONTASK, but things are a bit different in Windows. Is this the ?proper? way to do this since it will be run once daily? I considered a windows service but there is a level of complexity that I am not sure is justified.

Thoughts?

John Saunders
  • 160,644
  • 26
  • 247
  • 397
Sleepy
  • 93
  • 1
  • 9
  • 3
    A console application should be just fine. You can [hide the console window](http://stackoverflow.com/a/837567/1106367). – Adam Oct 17 '12 at 19:18
  • @codesparkle Thank you, I've been wondering for a while now how to do that, but never got around to searching for an answer. – Brian Snow Oct 17 '12 at 19:21
  • Do you mean that you want your program (or the installer?) to set up the task for the user automatically? – Harry Johnston Oct 17 '12 at 19:26

2 Answers2

6

If your app is doing small task every so often then a scheduled task is better as you'd be taking up system resources with a service sitting there doing nothing for most of the time.

If you're running your app on a recent version of windows then take a look in the control panel and search for "scheduled tasks". You will be able to set up a job to run your app daily in there.

Antony Scott
  • 21,690
  • 12
  • 62
  • 94
1

you will probably script this, so use schtasks.exe to create your scheduled tasks: msdn link to schtasks.exe

also, on win7 and later, you can actually migrate the created scheduled tasks in form of xml and import them onto another machine, it's a little easier to manipulate and/or save them if you want.

Alex
  • 2,342
  • 1
  • 18
  • 30