Hello, I am trying to execute a .bat from java, which has a command and must create a file with the output, the .bat works correctly, the problem is when I invoke it from the java program since it does not wait for it to finish and my file is created without content. I have also tried to execute the command directly if the .bat and the same thing happens to me. I'm trying like this, but it doesn't work, any ideas? thank you very much :) Process p= Runtime.getRuntime().exec(cmd);
try {
p.waitFor();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
You need to use /wait to keep the process open until the .bat finishes