title: How to execute a batch file from C#?
body: <p>(See end for solution)</p>
  
  <p>I didn't think this was going to be hard. I have a commmand file, d:\a.cmd which contains:</p>
  
  <pre><code>copy /b d:\7zS.sfx + d:\config.txt + d:\files.7z d:\setup.exe
  </code></pre>
  
  <p>But these lines of C# won't execute it:</p>
  
  <pre><code>Process.Start("d:\\a.cmd");
  Process.Start("cmd", "/c d:\\a.cmd");
  </code></pre>
  
  <p>Throws Win32Exception: "%1 is not a valid Win32 application."</p>
  
  <p>Process.Start opens .pdf files...why not execute command files?</p>
  
  <p>This works if I type it in a cmd window:</p>
  
  <pre><code>cmd /c d:\a.cmd
  </code></pre>
  
  <p>Windows XP, MS Visual Studio 2008.</p>
  
  <p>Thanks in advance,
  Jim</p>
  
  <p>SOLUTION
  I'm only SLIGHTLY embarrassed :( There was a file named cmd.exe, size zero in my app's dir. I have no idea how it got there but it is now toast and both of the above C# statements now work. I'm off to find a Harry Potter book so I can get some self-punishment ideas from Dobby...</p>