title: how to restart window service
body: <p>i want to restart window service named "Spooler" i did following code , but no luck, Any body has any idea about what is going on wrong?
  code is </p>
  
  <pre><code>using System.ServiceProcess;
  
  ServiceController service = new ServiceController("Spooler");
  
  if ((service.Status.Equals(ServiceControllerStatus.Stopped)) ||
      (service.Status.Equals(ServiceControllerStatus.StopPending)))
  {
      service.Start();
  }
  else
  {
      service.Stop();
      service.Start();
  }
  </code></pre>
  
  <p>exception is</p>
  
  <blockquote>
    <p>"System.InvalidOperationException: Cannot start service Spooler on
    computer '.'. ---> System.ComponentModel.Win32Exception: An instance
    of the service is already running</p>
    
    <p>--- End of inner exception stack trace ---</p>
    
    <p>at System.ServiceProcess.ServiceController.Start(String[] args)</p>
    
    <p>at System.ServiceProcess.ServiceController.Start()</p>
    
    <p>at servicerestart.Form1.button1_Click(Object sender, EventArgs e)
    in D:\samplecodes\servicerestart\servicerestart\Form1.cs:line 33"</p>
  </blockquote>