To start and stop the SharePoint Search Serivce just a few lines of code are needed:
 
static void StartService()
{
  try
  {
    System.ServiceProcess.ServiceController service = new System.ServiceProcess.ServiceController("SPSearch");
    if (service.Status == System.ServiceProcess.ServiceControllerStatus.Stopped)
      service.Start();
  }
  catch (Exception ex)
  {
  }
}
 
static void StopService()
{
  try
  {
    System.ServiceProcess.ServiceController service = new System.ServiceProcess.ServiceController("SPSearch");
    if (service.Status == System.ServiceProcess.ServiceControllerStatus.Running)
      service.Stop();
  }
  catch (Exception ex)
  {
  }
}
Advertisements