title: Passing a Batch File an Argument Containing a Quote Containing a Space
body: <p>On many occasions I have dealt with passing batch files arguments with spaces, quotes, percents, and slashes and all sorts of combinations of them. Usually I managed to figure out how to accomplish what I want, but this time I am stuck. I have tried a couple of hundred combinations now and my head is starting to hurt.</p>
  
  <p>I’ve reduced the problem to a—fairly—simple requirement: <strong>pass from one batch file to another, an argument that contains some space-delimited text, one of which is a quoted space</strong>. That is, one batch file should pass some string <code>X</code> to another so that the the second one echos <code>"A "B C" D"</code>. I just can’t figure out what <code>X</code> should be.</p>
  
  <p>Here is a minimal batch file that demonstrates some attempts that do not work. (This BAT file takes the place of both by calling itself.)</p>
  
  <pre><code>::Goal is to print:
  ::"A "B C" D"
  ::ie., pass from one BAT file to another a quote containing spaces and a quote containing a space
  @echo off
  if not (%1)==() goto print
  :passarg
    call %0 "A "B C" D"
    call %0 "A \"B C\" D"
         %0 "A ""B C"" D"
  :print
    echo %1
    pause
  </code></pre>
  
  <p>None of those attempts work. I’ve tried using <code>"\" \""</code>, <code>""" """</code>, <code>"""" """"</code>, <code>"\"" "\""</code>, <code>""\" \"""</code>, <code>"^" ^""</code>, <code>^"" "^"</code>, and so on. Either they print double double-quotes, lose everything after the space, or something else (that is wrong).</p>
  
  <p>Any ideas? Thanks.</p>