I want to execute 2 commands in windows operating system(one is batch file and other is python script) using Java Process Builder. But unfortunately not able to do that. I tried many ways.
List<String> commands = new ArrayList<String>();
commands.add("Testbatch.bat");
commands.add("Python.exe");
commands.add("TestPythonScript.py");
ProcessBuilder probuilder = new ProcessBuilder(commands);
Process process = probuilder.start();
Here it is executing Batch file but Not the python. Here Process builder is Treating the Commands as arguments except the first command. Also tried below approach but no luck.
String [] commands={"CMD","/C","Testbatch.bat","Python.exe","TestPythonScript.py"};
ProcessBuilder probuilder = new ProcessBuilder(commands);
Process process = probuilder.start();
Nothing worked for me to execute commands in sequence(one after other) by using ProcessBuilder, I almost spent 3 days but not able to find the correct approach. Can any one please suggest me the approach to achieve the same.
Thanks,
Sudheer