Материал из .Net Framework эксперт
demonstrates service control
/*
Mastering Visual C# .NET
by Jason Price, Mike Gunderloy
Publisher: Sybex;
ISBN: 0782129110
*/
/*
Example21_15.cs demonstrates service control
*/
using System;
using System.ServiceProcess;
public class Example21_15
{
public static void Main()
{
// connect to the Alerter service
ServiceController scAlerter = new ServiceController("Alerter");
Console.WriteLine(scAlerter.DisplayName);
Console.WriteLine(scAlerter.CanStop);
scAlerter.Stop();
Console.WriteLine("Service stopped");
scAlerter.Start();
Console.WriteLine("Service started");
}
}