Batch command parameter passing

March 13, 2009 at 11:22:40
Specs: Windows XP
I am having a problem passing parameters from one batch file (.bat) to another batch file(.bat). Following is detailed description. Please help.
test1.bat is calling test2.bat with the following parameters (below ).
test2.bat param1 param2 "/value "Order Type" "
In the receiving batch file the third parameter is getting string -> "/value "Order ONLY, rest is truncated. By analysis I think it is looking for first quote and second quote and the characters immediately following and breaks at the next space.
How can I pass the whole value of this third parameter which should be -> "/value "Order Type" "
Running this simple batch file on windows XP.
Thanks in advance.

See More: Batch command parameter passing

Report •

March 13, 2009 at 16:11:08
The problem is simple parameters a broken up according to double quotes and spaces.

Firstly anything inside double quotes(including spaces) and surrounded by spaces is interpreted as one parameter then any other parameters are allocated according to spaces alone.

What is happening above is that you are trying to put double quotes inside double quotes and command is interpreting them as two parameters:

%3 - "/value "Order <- order is include because there is no space after the quote.
%4 - Type" " <- same deal with no space before the quote.

If you want "/value "Order Type" " as the third parameter I can't see a way to do it. A very close and easy work around is available, use "%3 %4" instead of %3.

Report •

March 13, 2009 at 17:37:28
Thank you very much, appreciate your reply.

Report •

Related Solutions

Ask Question