I'm attempting to launch several batch files in their own windows using the Apache Commons Exec library, and although I'm able to launch them properly, I'm running into one small issue where the output from the JVMs being spawned are showing in the window for the original process. I need them to all display in their own separate windows, but despite using what I thought were the correct parameters, all the output dumps to the original console.
Here is how I am spawning the processes.
CommandLine cmd = new CommandLine("cmd");
cmd.addArgument("start");
cmd.addArgument("/MIN");
cmd.addArgument("/I");
cmd.addArgument("cmd.exe");
cmd.addArgument("/C");
cmd.addArgument(script);
cmd.addArgument(groupName);
Executor executor = new DefaultExecutor();
DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
try {
PumpStreamHandler psh = new PumpStreamHandler(new ExecOutputStream(LOG, Level.DEBUG), new ExecOutputStream(LOG, Level.ERROR));
executor.setWatchdog(watchdog);
executor.setExitValue(0);
executor.setStreamHandler(psh);
executor.execute(cmd, resultHandler);
resultHandler.waitFor(5_000);
} catch(IOException io) {
// handle IOException...
} catch(InterruptedException ie) {
// handle InterruptedException...
}
Is there a parameter for the start command I'm missing to cause these to spawn in their own console windows? Or is there some other method of the executor class that needs to be called?