Windows services consist of three components: a service application, a service control program (SCP), and the service control manager (SCM). First, we’ll describe service applications, service accounts, and the operations of the SCM. Then we’ll explain how auto-start services are started during the system boot. We’ll also cover the steps the SCM takes when a service fails during its startup and the way the SCM shuts down services.
Service Applications
Service applications, such as web servers, consist of at least one executable that runs as a Windows service. A user wanting to start, stop, or configure a service uses an SCP. Although Windows supplies built-in SCPs that provide general start, stop, pause, and continue functionality, some service applications include their own SCP that allows administrators to specify configuration settings particular to the service they manage.
Service applications are simply Windows executables (GUI or console) with additional code to receive commands from the SCM as well as to communicate the application’s status back to the SCM. Because most services don’t have a user interface, they are built as console programs.
When you install an application that includes a service, the application’s setup program must register the service with the system. To register the service, the setup program calls the Windows
When a setup program registers a service by calling
After creating a service, an installation or management application can start the service via the
When a program calls
The SCM stores each characteristic as a value in the service’s registry key. Figure 4-5 shows an example of a service registry key.
Table 4-7 lists all the service characteristics, many of which also apply to device drivers. (Not every characteristic applies to every type of service or device driver.) If a service needs to store configuration information that is private to the service, the convention is to create a subkey named Parameters under its service key and then store the configuration information in values under that subkey. The service then can retrieve the values by using standard registry functions.
Note
The SCM does not access a service’s Parameters subkey until the service is deleted, at which time the SCM deletes the service’s entire key, including subkeys like Parameters.
Value Setting
Value Name
Value Setting Description
Start
SERVICE_BOOT_START (0)
Winload preloads the driver so that it is in memory during the boot. These drivers are initialized just prior to SERVICE_ SYSTEM_START drivers.
SERVICE_SYSTEM_START (1)
The driver loads and initializes during kernel initialization after SERVICE_ BOOT_START drivers have initialized.
SERVICE_AUTO_START (2)
The SCM starts the driver or service after the SCM process, Services.exe, starts.
SERVICE_DEMAND_START (3)
The SCM starts the driver or service on demand.
SERVICE_DISABLED (4)
The driver or service doesn’t load or initialize.
ErrorControl