You can use one of the methods
System.Diagnostics.Process.Start
, for example:
System.Diagnostics.Process.Start(myBatchFileName);
or
System.Diagnostics.Process.Start(myBatchFileName, myBatchParameters);
All parameters are strings. First parameter is the batch file name (don't use CMD.EXE or something, use the batch file name only) and the optional second parameter is the list of batch file arguments written in one string, separated with black spaces.
You can also assign the reference to the child process you start as it is returned by these methods. You can use this variable for different purposes. In particular, you can put your calling thread of your parent process to a wait state until the batch file completes its execution using
Process.Wait
.
Finally, you can hide the console, redirect all the output of your batch file to a stream and read all text output from this stream. You will need to redirect at least to streams:
StandardOutput
and
StandardError
.
Please see:
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.aspx[
^].
You can find re-direction example here:
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.standardoutput.aspx[
^].
—SA