0

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#

8
  • a batch file to execute instructions.I am new to batch files..donno if you are asking abt specific files Commented Mar 1, 2011 at 21:01
  • Batch files aren't compiled. They're interpreted by cmd.exe (or command.com on older versions of Windows and in DOS). Commented Mar 1, 2011 at 21:01
  • Assuming the batch file is a 'command' batch file you can run it from c#, no need to compile, just look into System.Diagnostics.Process Commented Mar 1, 2011 at 21:02
  • 1
    If you really wanted, you could write your own batch interpreter :) Commented Mar 1, 2011 at 21:03
  • @rene..how do i know if it has errors...considering my fikle has errors.? Commented Mar 1, 2011 at 21:03

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.