This code snippet demonstrates how to get a list of windows services with status information.
Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceProcess;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
ServiceController[] services = ServiceController.GetServices();
foreach (ServiceController sController in services)
{
Console.WriteLine(sController.ServiceName + " " + sController.Status);
}
Console.ReadKey();
}
}
}
No comments:
Post a Comment