Display names of the Services and their status

Ddd
Posted by Ddd under C# category on | Points: 40 | Views : 1468
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//add this namespace
using System.ServiceProcess;

namespace ConsoleApplication1
{
class Class1
{
static void Main()
{
//simple example to display the services installed

//and their status.

//ServiceController class has been used. Add a reference to System.ServiceProcsss.dll

ServiceController[] z = ServiceController.GetServices();
foreach (ServiceController y in z)
{
Console.WriteLine(y.ServiceName + "---" + y.Status);

}
}
}
}

Comments or Responses

Login to post response