本文介绍了无法通过Jenkins从站设置从Java程序执行外部vb脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过Jenkins-从站设置(在Windows中运行),我们创建了一个ANT作业,该作业在内部调用下面的JAVA程序,

Through Jenkins - Slave setup (running in Windows), we have created a ANT job which in internally calls the below JAVA Program,

String[] command = {"cmd" , "/c", System.getProperty("user.dir")+"/Read_email/ReadEmail.vbs"};
Process p = Runtime.getRuntime().exec(command); 
System.out.println("Process Completed"); 

ReadEmail.vbs文件从不被调用或执行.没有错误消息或警告生成.

The ReadEmail.vbs file never gets called or executed.There is no error message or warning getting generated.

当我从eclipse或通过Master Jenkinks运行此Java程序时,VB Scripts被执行而没有任何错误.

When I run this java program from eclipse or through Master Jenkinks, VB Scripts gets executed without any errors.

推荐答案

您的

String[] command = {"cmd" , "/c", System.getProperty("user.dir")+"/Read_email/ReadEmail.vbs"};

依靠执行过程来知道在哪里可以找到cmd.exe以及谁需要调用.vbs.

relies on the executing process to know where to find cmd.exe and who to call for a .vbs.

我使用了完全冗余":

String[] command = {"C:/WINDOWS/system32/cmd.exe" , "/c", "C:/WINDOWS/system32/cscript.exe", "E:/trials/SoTrials/answers/21228622/java/callme.vbs"};
try {
    Process p = Runtime.getRuntime().exec(command);
} catch(Exception e) {
    System.out.format("%s\n", e.toString());
}

成功通过一个简单的命令行程序.我希望这种策略适用于您更复杂的Jenkins设置.

successfully from a simple commandline program. I hope this strategy works for your more complicated Jenkins setup.

这篇关于无法通过Jenkins从站设置从Java程序执行外部vb脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 10:56