‚ ‚
Windows, the .NET Framework SDK, and Visual Studio .NET provide various tools that help you to monitor and control a Windows service application. In this section, you'll learn how to work with each of these tools.
One of the easiest ways of manipulating a Windows service is through the Services MMC Snap-in. You can access this snap-in through either of the following:
Administrative Tools section of the Windows Control Panel.
By navigating to the Services and Application, Services node of the Computer Management tool. You can open the Computer Management tool by right-clicking on the My Computer and selecting Manage from the shortcut menu.
The Services snap-in lists all the Windows services installed on the computer along with their Name , Description, Status, Startup Type, and Logon Account, as shown in Figure 6.8.
You can select a service in this list and use the Action menu or the toolbar buttons to start, pause, continue, or stop a Windows service.
For more control options, you can display the property window for a service (see Figure 6.9) by double-clicking on the service record in the Services snap-in.
From the service property window, you can start, pause, continue, and stop the service. In addition to this, you have extra options to manipulate the startup type, start parameters, service login account. The Recovery tab allows you to specify actions that need to be taken if the service fails to start.
When using Visual Studio .NET, you need not leave the development environment to manipulate the Windows services. Visual Studio .NET allows you to manipulate services on both local and remote computers through the Server Explorer Window.
To access the services, open the Server Explorer Window and, in the Servers node, select the computer where you want to access the service. Inside the selected computer, you will find the node containing all the services on that computer, as shown in Figure 6.10. You can right-click a service and select options to start, pause, continue, and stop the Windows service from the shortcut menu.
The NET command-line utility comes installed with Windows. This utility allows you to perform various networking commands including control of Windows services. Typical usage of the net.exe with Windows services is as follows :
To enumerate a list of installed services
NET START
To start a Windows service
NET START WindowsServiceName
To pause a Windows service
NET PAUSE WindowsServiceName
To resume a paused Windows service
NET CONTINUE WindowsServiceName
To stop a Windows service
NET STOP WindowsServiceName
The Service Control command-line utility is the most powerful of all the service control tools that I discussed in this section. This utility comes installed with Windows XP and Windows .NET servers. It also comes as a part of Win32 SDK and the .NET Framework SDK.
The Service Control utility provides various options to start, pause, continue, stop, configure, and query a Windows service, as shown in Figure 6.11.
As an example, you can use sc.exe to set the description for a Windows service. To change the description of OrderService , you can use the following form of the sc.exe command:
[View full width]sc.exe description OrderService "This service listens to creation of order files (*.XML) in c:\orders directory. When a XML file is created in this directory, the XML data in the file is added as a new record to the Orders table of the NorthWind database"
You can confirm that the description is set by using the following command:
sc.exe qdescription OrderService
The Service Control utility provides a large number of options to work with Windows services. I'd recommend that you try several of these options to get comfortable with the usage of the utility.
‚ ‚ |
Top |