why to use windows service

hi

though i have used few windows services, yet i am not able to figure out , what specific problems it solves , and where specifically i should use them.

why not to use console app and put them in windows task scheduler rather.
BeyondBGCMAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

it_saigeDeveloperCommented:
The simplest answer is because services are generally application/programs/processes that run regardless of whether the user is signed in or not.  Another distinction is that *most* services, in general, need to run for as long as the operating system is loaded.

One example of this would be the Print Spooler:

Say that UserA needs to print and knows that UserB has a printer that is attached to his/her computer and that this printer is shared out for local network usage.  Now if UserB is not logged into his her computer, then something needs to be running on the computer to allow for a print request to be processed.  In this case, the Print Spooler service allows for UserA to send a print job to UserB's computer, the print spooler in turn sends the job to the target printer.  This process could not be accomplished by a scheduled task that is set to run as UserB because you never know explicitly when UserA will need to print.  Also, just leaving UserB logged in represents a hole in your security.

-saige-
0
it_saigeDeveloperCommented:
Also in the above example, other services come into play that allow for UserA to send a simple print job to UserB's computer.

-saige-
0
Jacques Bourgeois (James Burger)PresidentCommented:
Services are applications that look over other applications (such as an anti-virus program), or are used by other applications (such as SQL Server).

They cannot be started from the Task Scheduler, because you never know beforehand when they will be required.

At first sight, there are services that could be defined in a dll that runs only while an application uses it. Think of databases for instance. The Access database engine does not run continually on the computer, it is launched by the application that needs to Access the database, and then "dies" when the application stops.

You might Wonder why SQL Server runs as a service instead of doing the same thing that Access does. There are many reasons for that.

The main one is that it can be called from other computers. In order to do so, it needs to be ready to answer anytime.

On an individual station (SQL Server Express), because of all it does, SQL Server takes longer to start. It would slow down the first access to it from an application if an application needed to start it before using it.

Another one, more important that one, is that SQL Server still do work in the background even when applications do not use it. If it was to stop every time an application stops, it would not be able to do these background tasks efficiently.
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

BeyondBGCMAuthor Commented:
bit different solution, i can use task scheduler to start an application every minute, which is same as windows service,
0
it_saigeDeveloperCommented:
But that is because Task Scheduler, itself, is a windows Service.

-saige-
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
BeyondBGCMAuthor Commented:
if it is true , then it is the best answer to my question
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.