【发布时间】:2016-10-31 15:55:08
【问题描述】:
我在C:/work/selenium/chrome/ 中有一个 VBS 文件 test.vbs,我想从我的 Java 程序中运行它,所以我尝试了这个,但没有成功:
public void test() throws InterruptedException {
Runtime rt = Runtime.getRuntime();
try {
Runtime.getRuntime().exec( "C:/work/selenium/chrome/test.vbs" );
}
catch( IOException e ) {
e.printStackTrace();
}
}
如果我尝试使用此方法运行一些 exe 文件,它运行良好,但当我尝试运行 VBS 文件时,它显示“不是有效的 win32 应用程序”。
知道如何从 Java 运行 VBS 文件吗?
【问题讨论】:
-
显然在您的情况下,windows 不知道如何执行此命令。请使用执行器和脚本名称:类似:cscript C:\\work\\selenium\\chrome\\test.vbs