我只是尝试在 C 盘共享批处理文件夹中的服务器上运行批处理文件,但出现错误:
java.io.IOException: Cannot run program "sas.bat" (in directory "\\xx.xx.xx.xx\batch"): CreateProcess error=2, The system cannot find the file specified
java代码:
ProcessBuilder launcher = new ProcessBuilder();
launcher.redirectErrorStream(true);
launcher.directory(new File("\\\\xx.xx.xx.xx\\batch").getAbsoluteFile());
launcher.command("sas.bat");
Process p= launcher.start();
sas.bat:
"D:\sas home\SASFoundation\9.3\sas.exe" -SYSIN c:\codeexcel.sas
cmd /k
最佳答案
我怀疑,您可以直接使用像 \\server\folder
这样的 UNC 路径作为工作目录。
尝试使用整个路径(例如 \\server\folder\test.bat
)作为命令,也许可行。
如果没有,您必须先创建一个具有特定驱动器号的网络驱动器,然后使用该驱动器号执行命令。
关于java - 我只是想在 C 盘共享批处理文件夹中的服务器上运行批处理文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32943386/