【发布时间】:2013-02-22 22:32:50
【问题描述】:
我正在尝试将挂载命令作为 Java 进程执行。以下是我如何形成命令:
List<String> command = new ArrayList<String>();
command.add("cmd.exe");
command.add("/c");
command.add("mount.exe");
command.add("-u:" + username);
command.add("-p:" + password);
command.add(IP + ":" + mountPoint);
command.add(driveLetter + ":");
ProcessBuilder processBuilder = new ProcessBuilder(command);
processBuilder.redirectErrorStream(true);
Process process = processBuilder.start();
当我执行这个时,我得到错误,
'mount.exe' is not recognized as an internal or external command,
operable program or batch file.
我已经安装了mount.exe,并且在环境变量中设置了路径,
C:\>where mount.exe
C:\Windows\System32\mount.exe
C:\>path
PATH=C:\Windows\System32;C:\Windows; ... [removed the remaining entries]
当我在命令提示符下手动执行命令时,它工作正常:
C:\>cmd.exe /c mount.exe -u:<user> -p:<password> <IP>:<mount point> Z:
如果有人能指出我所缺少的,我将不胜感激。
谢谢。
【问题讨论】: