How to execute a batch file from C#?

Posted by Jim C on Stack Overflow See other posts from Stack Overflow or by Jim C
Published on 2010-06-11T23:36:57Z Indexed on 2010/06/11 23:42 UTC
Read the original article Hit count: 315

Filed under:
|
|

I didn't think this was going to be hard. I have a commmand file, d:\a.cmd which contains:

copy /b d:\7zS.sfx + d:\config.txt + d:\files.7z d:\setup.exe

But this line of C# wont' execute it:

Process.Start("d:\\a.cmd");

Throws Win32Exception: "%1 is not a valid Win32 application."

Process.Start opens .pdf files...why not execute command files?

Thanks in advance, Jim

© Stack Overflow or respective owner

Related posts about c#

Related posts about process