Solved

why to use windows service

Posted on 2014-10-02
6
46 Views
Last Modified: 2015-02-23
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.
0
Comment
Question by:BeyondBGCM
  • 3
  • 2
6 Comments
 
LVL 33

Expert Comment

by:it_saige
ID: 40357005
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
 
LVL 33

Expert Comment

by:it_saige
ID: 40357017
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
 
LVL 40
ID: 40357163
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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Comment

by:BeyondBGCM
ID: 40491910
bit different solution, i can use task scheduler to start an application every minute, which is same as windows service,
0
 
LVL 33

Accepted Solution

by:
it_saige earned 500 total points
ID: 40492109
But that is because Task Scheduler, itself, is a windows Service.

-saige-
0
 

Author Closing Comment

by:BeyondBGCM
ID: 40625741
if it is true , then it is the best answer to my question
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question