Using ShellExecuteW to call WEKA

 

I'm using ShellExecuteW from shell32.dll:

int value= ShellExecuteW(0, "open", "C:\test.bat", strParameters, "", 1);

The batch file runs WEKA to make a prediction which seems to open but returns an error and quickly the console window closes.

I want to capture the error from the console. I've tried adding the following re-directions at the end of my command in the batch file:

> output.txt 2> output.txt > output.txt 2>&1 1> output.txt 2>&1 | output.txt

I would expect these common commands to work but none of them result in anything being written in output.txt. What could I be doing wrong here?

I've tried ShellExecuteA and it does not open a command shell. If I run the batch file from the command line outside of MT5 it works with WEKA fine.

Do I need to use CreateProcess?

Thankyou for your help.
Reason: