Cannot execute external vb script from Java program through Jenkins Slave setup

拥有回忆 提交于 2020-02-07 07:26:05

问题


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"); 

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

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


回答1:


Your

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

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

I used a 'fully redundant':

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());
}

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



来源:https://stackoverflow.com/questions/21228622/cannot-execute-external-vb-script-from-java-program-through-jenkins-slave-setup

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!