我正在尝试将挂载命令作为 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:
如果有人能指出我所缺少的,我将不胜感激。
谢谢。