O'Reilly logo

Windows Server Cookbook by Robbie Allen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 7. Services

Introduction

Windows services are nothing more than continually running processes that are controlled by the Service Control Manager (SCM). Instead of directly creating a service process, you (or the system itself) sends a start or stop message to the SCM, which takes care of starting or stopping the associated process. The DHCP Client provided with the Windows operating system is an example of a service. It is responsible for requesting and renewing DHCP requests (i.e., obtaining an IP address dynamically), and, interestingly, performing dynamic DNS registrations. After the system begins the boot-up process, the SCM starts the DHCP Client service, which kicks off a process that runs in the background to handle DHCP requests. You can stop the DHCP Client service via the Services snap-in, which causes the SCM to terminate the underlying DHCP Client process. If you start the service, the SCM starts the process.

Each service has a corresponding key in the Registry contained under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services. This stores basic configuration information about the service including service dependencies, the command line to execute to start the service, and startup type (automatic, manual, or disabled). You can find the associated registry key for a service by running the following command:

> sc getkeyname "<ServiceDisplayName>"

For example, this returns the key for the DHCP Client service:

> sc getkeyname "DHCP Client" [SC] GetServiceKeyName SUCCESS ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required