abbas
abbas

Reputation: 61

C# - Compile a batch file programatically

Can i programatically compile a batch file form c#. Meaning that I give the location of the file and some C# Library compiles the file and gives the output

Can anyone tell me the library for C# that can help me write a small intepreter for C#

Upvotes: 0

Views: 522

Answers (2)

Oded
Oded

Reputation: 499132

Batch files in windows do not get compiled. They get executed by a command processor.

You can use Process.Start to execute a batch file from within a C# program.

Upvotes: 3

Eric Petroelje
Eric Petroelje

Reputation: 60518

If I assume this is just a regular windows batch file, you could run it like this:

System.Diagnostics.Process.Start('myfile.bat');

That will return a Process object. From there you can get the output stream from the process and read whatever text the batch file writes to the console.

Upvotes: 1

Related Questions