title: Cannot run a batch file from a Windows service in Windows server 2003 OS
body: <p>I am using the following code to run a batch file from C#. The following code is part of my windows service. This code works perfectly fine in Windows XP but when I deploy my windows service to Windows server 2003 OS it returns exit code 1 (failure). Does someone know what I am missing? Do I need to give some special permission to the windows service? The service is installed as a Local System service.</p>
  
  <pre><code>        ProcessStartInfo psi = new ProcessStartInfo();
  
          //specify the name and arguments to pass to the command prompt
          psi.FileName = ConfigurationManager.AppSettings["BatchFilePath"];
          psi.Arguments = fileName;
  
  
          //Create new process and set the starting information
          Process p = new Process();
          p.StartInfo = psi;
  
          //Set this so that you can tell when the process has completed
          p.EnableRaisingEvents = true;
  
          p.Start();
  
          //wait until the process has completed
          while (!p.HasExited)
          {
              System.Threading.Thread.Sleep(1000);
          }
  
          //check to see what the exit code was
          if (p.ExitCode != 0)
          {
              logger.Write("Exit Code" + p.ExitCode);
          }
  </code></pre>