Cmd / S is very useful, as it saves you from worrying about quoting quotes. Recall that the /C argument means "execute this command as if I typed it at the prompt and then exit."
So, if you have a complex command that you want to transfer to CMD.exe, you either need to remember the rules for quoting CMD arguments and properly avoid all quotes, or use /S , which runs the special non-parsing rule "Remove the first and last " and treat all other characters as a command to execute unchanged."
You would use it where you want to use the capabilities of the CMD shell, and not directly access another program. For example, expanding an environment variable, exiting or redirecting input, or using the built-in CMD.exe modules.
Example:
Use the built-in shell: this is done if you typed DEL /Q/S "%TMP%\TestFile" at the command line:
CMD.exe /S /C " DEL /Q/S "%TMP%\TestFile" "
This does SomeCommand.exe redirect the standard output to the temp file and the standard error to the same place:
CMD.exe /S /C " "%UserProfile%\SomeCommand.exe" > "%TMP%\TestOutput.txt" 2>&1 "
So, what gives /S extra? This basically eliminates the need to worry about quoting quotes. It also helps where you are not sure, for example, that the environment variable contains quotation marks. Just say /S and add an extra quote at the beginning and end.
Vaguely Linked: $ * to Bourne Shell.
Some background
Recall that the argument list main () is C-ism and Unix-ism. A Unix / Linux shell (for example, Bourne Shell, etc.) Interprets the command line, excludes arguments, extends wildcards, such as * , to file lists and passes the argument list to the program being called.
So if you say:
$ vi *.txt
The vi command, for example, sees the following arguments:
vi a.txt b.txt c.txt d.txt
This is because unix / linux works internally based on an "argument list".
Windows, which ultimately comes from CP / M and VAX, does not use this system internally. On the operating system, the command line is just one line of characters. The responsibility of the called program is to interpret the command line, expand file globes ( * etc.) and process fuzzy quoted arguments.
So, the arguments expected by C must be cracked by the C runtime library. The operating system provides only one line with in arguments, and if your language is not C (or even if it is), it cannot be interpreted as arguments separated by spaces specified in accordance with the rules of the shell, but as something completely different.