Using Tools to Monitor and Control a Windows Service

‚   ‚  


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.

Using the Services MMC Snap-in

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.

Figure 6.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 property window for a service (see Figure 6.9) by double-clicking on the service record in the Services snap-in.

Figure 6.9. The properties of a Windows service.

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.

Using Visual Studio .NET Server Explorer

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.

Figure 6.10. Visual Studio .NET Server Explorer allows 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 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  

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 .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.

Figure 6.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:

[View full width]
 
[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


MCAD. MCSD Training Guide (Exam 70-310. Developing XML Web Services and Server Components with Visual Basic. NET and the. NET Framework)
MCAD/MCSD Training Guide (70-310): Developing XML Web Services and Server Components with Visual Basic(R) .NET and the .NET Framework
ISBN: 0789728206
EAN: 2147483647
Year: 2002
Pages: 166

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net