title: How to pass some parameter to windows service when run programmatically
body: <p>i like to know that when we start &amp; stop win service programmatically from another apps then how could i pass some parameter to windows service programmatically....is it possible.</p>
  
  <p>here is my sample code which i use to start service programmatically.</p>
  
  <pre><code>private const int RestartTimeout = 10000;
  
  private readonly ServiceController service;
  
  public Control(string serviceName, string computerName)
  {
      service = new ServiceController(serviceName, computerName);
  }
  
  public Control(string serviceName)
  {
      service = new ServiceController(serviceName);
  }
  
  public bool StartService()
  {
      try
      {
          service.Refresh();
  
          if (service.Status == ServiceControllerStatus.Stopped)
          {
              service.Start();
              return true;
          }
  
          MessageBox.Show(string.Format("{0} --&gt; already started", service.DisplayName));
      }
      catch (Exception ex)
      {
          MessageBox.Show(ex.ToString(), @"Error Starting Service");
      }
  
      return false;
  }
  </code></pre>