Using Tools to Monitor and Control a Windows Service

Team-Fly    

Developing XML Web Services and Server Components with Visual C#™ .NET and the .NET Framework, Exam Cram™ 2 (Exam 70-320)
By Amit Kalani, Priti Kalani

Table of Contents
Chapter 7.  Windows Services


The Windows operating system, the .NET Framework SDK, and Visual Studio .NET provide various tools that help you to monitor and control a Windows service application.

Using the Services MMC Snap-In

One of the easiest ways to manipulate a Windows service is through the Service MMC snap-in. You can access this snap-in through the Administrative Tools section of the Windows Control Panel.

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. 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 by double-clicking on the service record 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 Explorer

When 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 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. You can right-click a service and select options to start, pause, continue, and stop the Windows service from the shortcut menu.

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 Windows services. Typical usage of 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 provides more detailed information and better control over the Windows service when compared to the other service-control tools discussed in this section. This utility comes installed with Windows XP and Windows .NET servers. 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 7.3.

Figure 7.3. The Service Control utility provides a powerful way to control and configure Windows services from the command line.

graphics/07fig03.jpg


    Team-Fly    
    Top


    MCAD Developing XML Web Services and Server Components with Visual C#. NET and the. NET Framework Exam Cram 2 (Exam Cram 70-320)
    Managing Globally with Information Technology
    ISBN: 789728974
    EAN: 2147483647
    Year: 2002
    Pages: 179

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