ProcessBuilder.directory(java.io.File)
define the working directory of the process, not the "launch", so:
case 1: QQ.exe
is started with working directory D:\\Program Files (x86)\\Tencent\\QQ\\Bin\\
but QQ.exe
is not found (not in %PATH%
)
case 2: cmd.exe
is started with working directory D:\\Program Files (x86)\\Tencent\\QQ\\Bin\\
then QQ.exe
is launched and found (cmd is in %PATH%
and QQ.exe
in current working dir)
We can assume that ProcessBuilder
starts the process then perform a working directory change.