title: Does the Windows "cmd.exe" parse arguments differently?
body: <p>It seems to me that how the Windows <code>cmd.exe</code> parses argument string is different from how normal a C-compiled exe does it.</p>
  
  <p>To illustrate, <code>cmd /C "echo ok"</code> prints "ok" correctly. But, <code>cmd "/C" "echo ok"</code> results in</p>
  
  <pre><code>'"echo ok' is not recognized as an internal or external command,
  operable program or batch file.
  </code></pre>
  
  <p>For comparison, here is a C program, "CommandArguments.c", that prints arguments line-by-line:</p>
  
  <pre><code>int main(int argc, char *argv[])
  {
      int i;
      for (i = 0; i &lt; argc; ++i) {
          printf("%s\n", argv[i]);
      }
  }
  </code></pre>
  
  <p>If I run <code>CommandArguments.exe "/C" "echo ok"</code>, it correctly prints</p>
  
  <pre><code>CommandArguments.exe
  /C
  echo ok
  </code></pre>
  
  <p>I'm asking this because I'm implementing an API to wrap <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx" rel="nofollow"><code>CreateProcess</code></a>. I quotes and escape all input arguments before passing to <code>CreateProcess</code>. It works for most things but not the <code>cmd</code> due to the above issue.</p>
  
  <p>So, I want to know why the <code>cmd</code> behaves differently? What is its argument parsing rule? Is there any other program also parse arguments in different ways?</p>