book
Article ID: KB0092478
calendar_today
Updated On:
Description
Resolution:
When passing arguments to a command service in Windows you must use an array of strings instead of a single string. This is because of a difference in how Windows and Unix process a single-string command coming from java.lang.Runtime.exec(). In Unix, the shell does the command parsing. In Windows, the process does it. (For more info on this, Google: runtime exec windows quotes.)
So the problem is that if you provide the arglist as a single string such as:
String arglist ="-commandline 0 -dbarg \"asdf:dsdf\" -test1 0";
s.submit("",new Object[] {arglist}, handler,(Condition)pd);
Windows does not process that correctly.
However, if you pass the arguments as an array of strings, instead of a single string, the array of strings get passed to RuntimeExec(String cmdarray,...) and then Windows handles it properly:
String[] arglist = new String{"-commandline", "0", "-dbarg", "\"asdf:dsdf\"", "-test1", "0"};
s.submit("",arglist, handler,(Condition)pd);
Issue/Introduction
Passing arguments to a command service in Windows as a single string fails