Csharp/C Sharp by API/System.ServiceProcess/ServiceController
Содержание
new ServiceController
using System;
using System.ServiceProcess;
public class MainClass
{
public static void Main()
{
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");
}
}
ServiceController.CanStop
using System;
using System.ServiceProcess;
public class MainClass
{
public static void Main()
{
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");
}
}
ServiceController.DisplayName
using System;
using System.ServiceProcess;
public class MainClass
{
public static void Main()
{
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");
}
}
ServiceController.Stop()
using System;
using System.ServiceProcess;
class MainClass
{
public static void Main()
{
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");
}
}