Java Runtime Exec for VBA script with arguments

放肆的年华 提交于 2019-12-06 12:01:38

I think I need to use the String[] overloaded method for exec

Exactly! Change your command to be a String array. The array must contain the command and its arguments:

String[] command = {"cmd","/c", "concat2.vbs", arg1, arg2};
Process p = Runtime.getRuntime().exec(command);

concat2.vbs should be on Window's execution path (same directory, or configured in the PATH environment variable)

Check out the documentation for the Runtime class.

Something like:

String[] cmd = { "cmd", "/c", "concat2.vbs" "dog" "house" };
Process p = Runtime.getRuntime().exec(cmd);

Should produce 'doghouse'

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