Java Runtime Exec for VBA script with arguments
I am trying to use Runtime exec () to run a vba script with arguments. I have problems passing through Artsakh. I think I need to use the overloaded String [] method for exec.
This currently works:
String command = "cmd /c \"\\concat2.vbs\""
Process p = Runtime.getRuntime().exec(command);
But I want to run this with arguments and if I do this
String command = "cmd /c \"\\concat2.vbs\" " + arg1 + " " + arg2
where arg1 and arg2 are the lines my program won't run (status = 1)
+2
a source to share
2 answers
I think I need to use the String [] overloaded method for exec
Exactly! Modify the command as a String array. The array should contain the command and its arguments:
String[] command = {"cmd","/c", "concat2.vbs", arg1, arg2};
Process p = Runtime.getRuntime().exec(command);
concat2.vbs
must be in the windows execution path (same directory or configured in PATH environment variable)
Check out the documentation for the Runtime class .
0
a source to share