Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Console Application versus Windows Service

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?

like image 511
Sleepy Avatar asked Oct 17 '12 19:10

Sleepy


People also ask

What is the difference between console application and Windows Service?

The key difference between a process running as an app versus as a service is that the service can operate entirely outside the normal association with a user and session. Thus services can run such that they start before any user logs in and can continue running after users log off.

Can I run console app as Windows Service?

NET Windows apps that can run as console apps or as Windows Services. You can quickly hook up events such as your service Start and Stop events, configure using code e.g. to set the account it runs as, configure dependencies on other services, and configure how it recovers from errors.

What is a Windows console application?

A console application facilitates the reading and writing of characters from a console - either individually or as an entire line. It is the simplest form of a C# program and is typically invoked from the Windows command prompt.


2 Answers

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.

like image 141
Antony Scott Avatar answered Sep 30 '22 10:09

Antony Scott


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.

like image 26
Alex Avatar answered Sep 30 '22 09:09

Alex