When executing some command(let's say 'x') from cmd line, I get the following message: "....Press any key to continue . . .". So it waits for user input to unblock.
But when I execute the same command ('x') from java:
Process p = Runtime.getRuntime().exec(cmd, null, cmdDir);
// here it blocks and cannot use outputstream to write somnething
p.getOutputStream().write(..);
the code blocks...
I tried to write something into the process's output stream, but how can i do that sice the code never reaches that line ?
So this is my workaround to this problem, inspired from Alnitak's suggestion: Run the command like this:
the 'someTextFile.txt' can be programatically created into the temporary dir then deleted.
I had the same problem and I found a solution. It ins´t the most elegant, but it works.
1 - when you execute the process, you get the inputStream from the process 2 - Then you make a loop receiving the message shown in the prompt, if there was one 3 - When you see that you got from "prompt" the "press a key to continue", or whatever, you end the proccess