It's quite possible i've misunderstood the purpose of the File dir argument in Runtime.exec(String command, String[] envp, File dir):
"The working directory of the new subprocess is specified by dir. If dir is null, the subprocess inherits the current working directory of the current process."
If I run Runtime.exec("C:/mydir/myfile.bat"); the script is executed (albeit with the wrong working dir)
however if I run Runtime.exec("myfile.bat", null, new File("C:/mydir")); i get the following error:
java.io.IOException: Cannot run program "myfile.bat" (in directory "C:\mydir"): 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)
I would assume that the dir argument sets the working directory for the new process as well as the command being executed, however maybe it just does the former. if that is the case the exception message is quite misleading.