This sample shows some how to control an installed Windows Service from code.
The code demonstrates how to build an application that can be used to enumerate all and control any of the Windows Services that are currently installed on the local maching. This includes forcing the Windows Service to start, stop, pause, and continue. In addition, the code demonstrates how to replicate the functionality of a service controller like the SQL Service Service Manager application, that ships with SQL Server. This functionality demonstrates the use of the NotifyIcon and ContextMenu controls.
To run the sample:
System.ServiceProcess Namespace, ServiceBase Class