开发者

C# - Compile a batch file programatically

开发者 https://www.devze.com 2023-02-14 17:42 出处:网络
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 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#


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消