Microsoft® Windows® 2000 Scripting Guide
« Previous | Next »
Services are an important part of the Microsoft® Windows® 2000 operating system. A service, which is similar to the daemons used in the UNIX operating system, is an application that can communicate with and be administered by the Service Control Manager (SCM). In addition, a service can:
These capabilities not only make services vitally important to the way computers function, but also make system administration viable. For example, without the DHCP service, an administrator would have to manually configure each computer s IP address. Without the DNS service, an administrator would have to manually configure and maintain Hosts or Lmhosts files. Without the automated capabilities of services, these tasks simply could not be performed in an enterprise setting.
Because services play such an important role in an organization s computing infrastructure, service management is a crucial part of any system administrator s job. If a service stops functioning, it affects the computer on which the service runs. Depending on the service, however, it could also adversely affect many users and their computers. If the DHCP service fails, computers are not given IP addresses, and users lose network connectivity. If the DNS service fails, the Active Directory® directory service is unavailable, and users cannot locate domain resources.
Managing services helps ensure that:
Services, like other applications, are run from executable files. For example, the DNS service runs in an instance of systemroot\system32\dns.exe, and Internet Information Services runs in an instance of systemroot\ system32\inetsrv\inetinfo.exe.
However, services are a special type of application. Unlike the executable files for most applications, the executable file for a service includes code that enables it to perform the special functions of a service and to communicate with the SCM.
To run an application as a service, the following components (some part of the operating system, some part of the individual service) must be present.
The SCM provides a unified means for configuring and managing services. In particular, the SCM does the following:
The Services snap-in to the Microsoft Management Console (MMC) is an example of a service control program, as are Sc.exe and the Net Start and Net Stop commands. Windows Management Instrumentation (WMI) scripts can also function as service control programs.
When a Windows 2000 based computer starts, the executable file for SCM (Services.exe) begins running before the logon dialog box appears. This allows autostart services to start before any user logs on.
After Services.exe starts, the SCM scans the contents of the registry subkey HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services. For each service listed in the registry, the SCM creates a corresponding entry in the services database. It establishes channels for communicating with service control programs and then starts the autostart services.
When a service starts, it initializes a minimum of two threads. One thread is used to communicate with the SCM and the other is used to respond to requests from client applications. For example, a Web server service creates a TCP "listen socket" and waits for inbound HTTP requests. When such a request is received, the thread becomes active, processes the request, and then suspends itself until the next request arrives. An application that initializes only a single thread cannot run as a service.
Send us your feedback | « Previous | Next » |