I need to execute a batch file (in Java 6) and use following code for this:
final String command = "C:\Ruby191\bin\mygem.bat inputfile.dat";
final File parent = new File(aParentDir);
Process proc;
proc = aRuntime.exec(command, null, parent);
But I get this exception:
...Exception: java.io.IOException: Cannot run program "
C:\Ruby191\bin\mygem.bat" (in directory "src\test\resources\...
"): CreateProcess error=267, Directory name invalid
The batch file in question exists in the specified directory.
What is wrong in my code?
Try using double backslashes \\
or single slashes /
instead of single backslashes. Check current directory name too.