title: What is `cmd /s` for?
body: <p>The Windows command prompt (<code>cmd.exe</code>) has an optional <a href="http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/cmd.mspx?mfr=true"><code>/s</code> parameter</a>, which modifies the behavior of <code>/c</code> (run a particular command and then exit) or <code>/k</code> (run a particular command and then show a shell prompt). This <code>/s</code> parameter evidently has something to do with some arcane quote handling.</p>
  
  <p><a href="http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/cmd.mspx?mfr=true">The docs</a> are confusing, but as far as I can tell, when you do <code>cmd /c</code><em><code>something</code></em>, and the <em><code>something</code></em> contains quotation marks, then by default <code>cmd</code> will sometimes strip off those quotes, and <code>/s</code> tells it to leave them alone.</p>
  
  <p>What I don't understand is when the quote removal would break anything, because that's the only time <code>/s</code> ("suppress the default quote-removal behavior") would be necessary. It only removes quotes under a certain arcane set of conditions, and one of those conditions is that the first character after the <code>/c</code> must be a quotation mark. So it's not removing quotes around arguments; it's either removing quotes around the path to the EXE you're running, or around the entire command line (or possibly around the first half of the command line, which would be bizarre).</p>
  
  <ul>
  <li>If the path to the EXE is quoted, e.g. <code>cmd /c "c:\tools\foo.exe" arg1 arg2</code>, then quotes are unnecessary, and if <code>cmd</code> wants to remove them, fine. (It won't remove them if the path has a space in the name -- that's another of the arcane rules.) I can't imagine any reason to suppress the quote removal, so <code>/s</code> seems unnecessary.</li>
  <li>If the entire command line is quoted, e.g. <code>cmd /c "foo.exe arg1 arg2"</code>, then it seems like quote removal would be a necessity, since there's no EXE named <code>foo.exe arg1 arg2</code> on the system; so it seems like opting out of quote removal using <code>/s</code> would actually break things. (In actual fact, however, it does not break things: <code>cmd /s /c "foo.exe arg1 arg2"</code> works just fine.)</li>
  </ul>
  
  <p>Is there some subtlety to <code>/s</code> that's eluding me? When would it ever be necessary? When would it even make any difference?</p>