This code will help you to find specific service is installed on your machine or not. This program first find the list of services installed on your machine and then compare with given service.
Code : Find Windows Service
using System;
using System.ServiceProcess;
namespace ConsoleApp
{
class Program
{
static void Main(string[] args)
{
string find_service = "SQLWriter";
ServiceController[] service_list = ServiceController.GetServices();
bool bfound = false;
foreach (ServiceController my_service_list in service_list)
{
if (find_service == my_service_list.ServiceName)
{
Console.WriteLine(my_service_list.ServiceName + " is already installed.");
bfound = true;
break;
}
}
if(!bfound)
Console.WriteLine(find_service + " is not installed.");
Console.ReadLine();
}
}
}
Nice. Thanks
ReplyDelete