Can somebody find what is wrong with this code:
Runtime rt = Runtime.getRuntime();
Process pr;
File myFolder = new File("C:\\Temp");
pr = rt.exec("myExec.bat", null, myFolder);
pr.waitFor();
pr.destroy();
When I run this code, I get following exception (while file and folder used exist as specified):
java.io.IOException: Cannot run program "myExec.bat" (in directory "C:\Temp"): CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(ProcessBuilder.java:460)
at java.lang.Runtime.exec(Runtime.java:593)
at java.lang.Runtime.exec(Runtime.java:431)
at com.radml.radmlp.main(Test.java:10)
rt.exec expects a file with no path information to be in the user dir and not in the directory you specify to use as working directory. Using it this way
should work as long as your file c:\Temp\myExec.bat exists.
Greetz,
GHad