Windows Services in .NET
page 4 of 10
by Kavitha Pradeep
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 44658/ 101

Service Control Manager (SCM)

Due to the fact that services have no desktops, they usually do not interact with the users. But there has to be a way for controlling and managing these services. Service Control Manager does just that.

The SCM, a part of the windows kernel, is the one that controls the lifetime of the service. Any process that needs to be started and stopped like a service has to register itself with the SCM. The SCM then takes care of when to launch the service and when to stop it. The SCM holds a list of all the installed services, when they should be started, whether they should be allowed to interact with the desktop, etc.


The administrator can control services by sending control requests to them (e.g. "start service", "stop service", etc.) via the SCM. This is done using the Services applet of the control panel; double-clicking on the icon brings up the Services window, which lists all the services in the SCM database. Another utility to view the services running is WinMsd.exe. Combining the functionalities available in these two utilities, with an additional capability to control and configure the services on remote computers is Service Controller (SC.exe). This utility is not pre-installed with windows and has to be downloaded to every computer that needs it. All these utilities use the SCM to communicate with the services.


The SCM maintains its database of services installed in the system in the registry. Each service has an entry in the following key:


  HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\<Service Name>


Here, the Service Name is the name of the service used by the SCM. The service name seen in the Services applet is different from this one. This is a unique name used internally by the SCM. The corresponding name of each service which is displayed in the applet is stored in the key Display Name inside the Service Name key.


Each service can run by logging on as either a Local System or particular user account. Also the services can be enabled or disabled for specific hardware profile. Each service could either run independently or it will depend on some other service(s). The list of services each service depends on will be maintained by the SCM. All these information could be seen from the Services applet by looking at the properties of each service. Other than the list of services a particular service depends on, a list of services that depend on this service can also be seen.


When a service fails, the SCM can decide what action to take. These can be specified directly through the Service applet. The possible actions are:

·        Restart the service

·        Run a particular file

·        Reboot the computer

·        Take no action

By default the response for a failure is to take no action. If the service fails for the second time too, one of these actions can be set. For subsequent failures, another action could be assigned.


Building a service is a little complicated in the sense that a certain steps have to be followed to successfully build and install a service. Prior to .NET, the only efficient way to build a .NET was by building it in C++/ VC++. It was complicated and had various issues to be considered while doing it. But .NET has changed the way the services were build. With its Framework Base Classes available as a part of the .NET Framework, building services were made easy. By taking advantage of the object oriented capability of .NET, various tasks needed to build a service has been greatly simplified by encapsulating them inside various classes and including them as a part of the .NET Framework Base Classes. These base classes in the .NET Framework take care of the system-level interfacing.

View Entire Article

User Comments

Title: Windows Services   
Name: S.B.krishna Reddy
Date: 2010-12-31 4:29:52 AM
The images u have presented in the web page are not proper and not showing the clear view
Title: Windows Service in .NET 2   
Name: sbanik
Date: 2009-10-14 6:24:58 AM
Title: Windows Services in .NET   
Name: Nanthakumar
Date: 2008-10-16 6:53:15 AM

This is Very Useful my project..

Title: Extremely helpful, even after 4 yrs~   
Name: Rajeev
Date: 2008-06-12 4:40:13 AM
Thanks a lot for this article. It's been 4 yrs since it was authored, but yet it is so useful for beginners.

Thanks a ton.
Title: Learned Windows services   
Name: Debasmit Samal
Date: 2008-01-23 1:16:47 AM

Thanks a lot and lot for the article.
Really i got basic concepts for the windows services.

Thanks again for such a nice article.
Title: Windows Service   
Name: Rohini S
Date: 2008-01-22 3:28:06 AM
It is an excellent tutorial. It covers basics of Windows service. It is a good for beginners
Title: Crystal report autogeneration using windows services   
Name: Rajesh m
Date: 2007-08-09 9:03:43 AM
Hi All,
I developed windows service which will daily at 12:00pm generate crystalreports and mail is sent to the mail with crystal report attached. Here my problem is it works fine in my system..but when i put in testing server it is not working...
Title: windows service   
Name: pawar megha p.
Date: 2007-05-03 5:00:26 AM
very good article for windows services.i have problem for writting the Installutil.exe in command propmt of gives no file found,so what may be the problem?

Title: Windows Service   
Name: M.Mansoor AliKhan
Date: 2006-11-13 2:32:37 AM
This is really a knowledge providing article.

Thanks ..
Title: Running Windows Service from Web Service   
Name: Shantanu Karmakar
Date: 2006-08-18 6:19:41 AM
I'm having a problem to start and stop a windows service from my web service. It's giving an exception InvalidIOException - Couldn't strat service. Can any one help in this regard? I think the problem is with the security.
Title: How do we programmatically configure a Windows Service to interact with the desktop?   
Name: Shashi Kumar
Date: 2006-07-29 9:15:19 AM
Can u please let me know how do I make the windows service interact with the desktop since the windows service has to invoke a windows application upon its successful start?
Please let me know where exactly a property called "AllowServiceToInteractWithDesktop" exists and how do I use it?

I have been struck for quite sometime now... and any help would be greatly appreciated.

Feel free to mail me at

Thanks in advance.
Title: Webservice   
Name: Mahendra
Date: 2006-07-19 1:58:51 AM
this is really a knowledge providing article.
Title: User Interface   
Name: Uli
Date: 2006-06-20 8:14:30 PM
"Although it’s possible, Windows Service typically has no user interface."

Hi, great article, how can I find more information about creating a windows service with windows interface, so far everytime that my windows service timer goes off and executes some code, all the functionality will work as needed but because it won't show the form that I developed (This is actually my biggest problem), it will limit my application's functionality.

Any ideas???

If you guys have something please let me know:

Title: windows services   
Name: shan
Date: 2006-05-08 10:45:38 AM
this explaination is good but is this possible to install the windows services without the use of installutl i mean calling just the function install() , i tried it but its giving "no object reference " problem i think the problem is with the hashtable may be its not having the proper context?
i need ur help
Title: Windows Service Behaviour   
Name: Deepak
Date: 2006-04-27 7:28:58 AM
Hello, I have problem with Windows Service that I have created in VB.Net its behaviour is really strange i.e.Sometimes after Istallation and Start it runs but sometimes it just stucks somewhere.Then again this service needs to be re-installed(not just restart) then it runs perfectly very well.
This service does some Asynchronous task using delegates.
I could not understood this behaviour,let me know how can I understand it or what could be reasons.

Title: windows services   
Name: shravan
Date: 2006-04-03 4:24:51 AM
this is ok
now whether this is possible to install this service without installutil.exe i mean just adding entries in the registry by urself
well i am a newbie

Community Advice: ASP | SQL | XML | Regular Expressions | Windows

©Copyright 1998-2023  |  Page Processed at 2023-03-23 9:58:34 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search