package needl;
import java.io.*;
import java.util.concurrent.*;
/**
* @author Hardneedl
*/
final class ScriptRunDemo {
public static void main(String[]args) throws IOException, InterruptedException {
//creat demo shell script
PrintWriter fout = new PrintWriter("scriptDemo.cmd");
fout.print("DIR C:\\");
fout.flush();
fout.close();
ProcessBuilder processBuilder = new ProcessBuilder("scriptDemo.cmd");
processBuilder.redirectError(ProcessBuilder.Redirect.appendTo(new File("processbuilder_error.txt")));
processBuilder.redirectOutput(new File("processbuilder_output.txt"));
Process process = processBuilder.start();
boolean successed = process.waitFor(4L, TimeUnit.SECONDS);
process.destroy();
}
}