获取:java.io.IOException:无法运行程序" sas.bat" (在目录" \\ xx.xx.xx.xx \ batch"):CreateProcess error = 267,目录名无效

时间:2015-10-05 04:55:44

标签: java batch-file sas

我想在服务器名称上运行批处理文件xx.xx.xx.xx来自我的本地机器**(yy.yy.yy.yy)**。我的批处理文件存在于批处理文件夹中的c驱动器中,该文件夹是共享的,但是在运行java程序之后它给出了错误,即

java.io.IOException: Cannot run program "sas.bat (in directory "\\xx.xx.xx.xx\batch"): CreateProcess error=267, 

目录名无效

at java.lang.ProcessBuilder.start(Unknown Source)".

提前感谢。

Java代码:

try {


            ProcessBuilder launcher = new ProcessBuilder();
            Map<String, String> environment =launcher.environment();
            launcher.redirectErrorStream(true);

            launcher.directory(new File("\\\\xx.xx.xx.xx\\batch"));
                launcher.command("sas.bat");
            Process p= launcher.start();

                } 
                   catch (Exception e) 
                {

                System.out.println("Execution error");
                e.printStackTrace();
                } 

sas.bat:

"D:\sas home\SASFoundation\9.3\sas.exe" -SYSIN c:\codeexcel.sas
cmd /k

1 个答案:

答案 0 :(得分:1)

我试过这个并且它的工作: 注意:F:\ Softwares \ PsTool是PsExec.exe的路径

 ProcessBuilder builder = new ProcessBuilder("cmd.exe", "/c",
                    "F:\\Softwares\\PsTool\\PsExec.exe \\\\xx.xx.xx.xx -u Administrator -p yyyy \"c:\\batch\\createFolder.bat\"");