I need to pass parameters with spaces to a command wrapped in batch file. I need to trigger the same from my code in java.
I have tried to pass the parameters in double quotes but still it is taking the value inside the quotes which is with spaces and hence couldn't execute the command. The command wrapped in batch file is - msend -n {server} -a {event} -b "mc_object_class=%par1%;mc_parameter=%par2%;support_group=%par3%"
The java method I have used to trigger the same is - Process process = new ProcessBuilder("C:/test.bat", "\""+object_class+"\"", "\""+mc_parameter+"\"", "\""+support_grp+"\"").start();
Parameters with quotes and without quotes are treated as same from java, whereas from command prompt it works fine with double quotes. Need to know the way to pass parameters with spaces from ProcessBuilder method.
Runtime.getRuntime().exec() method also giving the same error. My work is stuck at this point.
Any help will be highly appreciated.