May 28, 2011, 8:26 p.m.
posted by fractal
Using Tools to Monitor and Control a Windows ServiceThe .NET Framework SDK and Visual Studio .NET provide various tools that help you monitor and control a Windows service application. In this section, you'll learn how to work with each of these tools. Using the Services MMC Snap-inOne of the easiest ways to manipulate a Windows service is through the Service MMC Snap-in. You can access this snap-in through either of the following:
The Services snap-in lists all the Windows services installed on the computer, along with the Name, Description, Status, Startup Type and Logon Account for each one, as shown in Figure. 8. The Services snap-in enumerates the installed Windows services on a computer.
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 Properties window for a service (see Figure) by double-clicking on the service record in the Services snap-in. 9. You can access the control options of a Windows service by using its Properties window in the Services snap-in.
From the service's Properties 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, and service login account. The Recovery tab enables you to specify actions that need to be taken if the service fails to start. Using Visual Studio .NET Server ExplorerWhen using Visual Studio .NET, you need not leave the development environment to manipulate the Windows services. Visual Studio .NET enables 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 Server 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. You can right-click a service and select options to start, pause, continue, and stop the Windows service from the shortcut menu. 10. Visual Studio .NET Server Explorer enables you to control Windows services without leaving the development environment.
Using the NET Utility (net.exe)The NET command-line utility comes installed with Windows. This utility enables you to perform various networking commands, including control of Windows services. Typical usage of the net.exe with Windows services is as follows:
Using the Service Control Utility (sc.exe)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 Server 2003. This utility also comes as a part of the 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. 11. The Service Control utility provides a powerful way to control and configure Windows services from the command line.
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: 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 query the description 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 you try several of these options to get familiar with the utility's usage. |
- Comment



