I'm running Linux, but the same error occurs when I run your code (modified to run a .sh rather than .bat).
Try:
ProcessBuilder pb = new ProcessBuilder("c:\adb.bat");
Apparently using ProcessBuilder.directory
doesn't affect the working directory (for the purposes of discovering the executable) that was chosen when the builder was constructed (at least, that's what seems to happen. The docs say it will change the working directory, so I guess input/output files might be relative to that?)
I'm not sure what it's actually doing internally, but providing the path to the executable in the constructor fixed the problem.
This post talks about the problem and this solution, but also raises whether environment variables have to be set, of which "path"-like variables might be useful to help ProcessBuilder
discover an executable.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…