Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Runtime Exec for VBA script with arguments

I am trying to use Runtime exec() to run a vba script with arguements. I am having trouble passing in the args. I think I need to use the String[] overloaded method for exec.

Currently this works:

String command = "cmd /c \"\\concat2.vbs\""

Process p = Runtime.getRuntime().exec(command);

But I want to run that with arguments and if I do this

String command = "cmd /c \"\\concat2.vbs\" " + arg1 + " " + arg2

where arg1 and arg2 are strings my program doesnt run (status = 1)

like image 389
Holograham Avatar asked May 22 '26 17:05

Holograham


1 Answers

Something like:

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

Should produce 'doghouse'

like image 73
decompiled Avatar answered May 25 '26 05:05

decompiled



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!