title: execute php command using C# windows service not working
body: <p>I'm writing a program which creates a PDF at various intervals of time. I'm trying to run a PHP command to generate the PDF using a windows service (C#).</p>
  
  <p>My code works just fine from within a C# windows desktop app, but when I try to use it in a windows service, nothing happens and the <strong>exit</strong> line appears in output without generating a PDF file.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>     ProcessStartInfo cmdStartInfo = new ProcessStartInfo();
              cmdStartInfo.FileName = @"cmd.exe";
              cmdStartInfo.RedirectStandardOutput = true;
              cmdStartInfo.RedirectStandardError = true;
              cmdStartInfo.RedirectStandardInput = true;
              cmdStartInfo.UseShellExecute = false;
              cmdStartInfo.CreateNoWindow = true;
              cmdStartInfo.ErrorDialog = false;
              cmdStartInfo.WindowStyle = ProcessWindowStyle.Hidden;
              cmdStartInfo.WorkingDirectory = WorkingDirectory; //refers to directory where php file exist.
  
              Process cmdProcess = new Process();
              cmdProcess.StartInfo = cmdStartInfo;
              cmdProcess.ErrorDataReceived += cmdProcess_ErrorDataReceived;
              cmdProcess.OutputDataReceived += cmdProcess_OutputDataReceived;
              cmdProcess.EnableRaisingEvents = true;
              cmdProcess.Start();
              cmdProcess.BeginOutputReadLine();
              cmdProcess.BeginErrorReadLine();
              cmdProcess.StandardInput.WriteLine(@"php.exe -c  GeneratePDF.php ");
              cmdProcess.StandardInput.WriteLine("Exit");
  </code></pre>