I have a batch file that sets JAVA_HOME, PATH and CLASSPATH and calls a jar file. The last line in the batch file is "java -classpath test.jar test %1". When I run the batch file from the command line, using a paramater, the parameter displays in the console as expected.
Now, I need to capture the result in a c# process. In the code below I expect to see the word "testing" in process.StandardOutput, but I only see the contents of the batch file. Can anyone help? Thanks
string batch_file = @"C:\java\runit.bat";
Process process = new Process();
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.UseShellExecute = false;
process.StartInfo.FileName = batch_file;
process.StartInfo.Arguments = "testing";
process.Start();
process.WaitForExit();
if (process.HasExited)
MessageBox.Show(process.StandardOutput.ReadToEnd());