Code: Select all
cmd /c echo 123
This is because TC runs the command using cmd.exe /K "<command>". TC adds quotes, probably because of the complex quote stripping behavior of cmd.exe when using /C or /K. Commands executed via these paramaters are not treated the same way as when they are typed in a command prompt window. The quotes added by TC are stripped in most cases, but not always. So the commands on TC's command line are still not always executed as entered by the user.123"
The solution would be to add parameter /S, so to use cmd.exe /S/K "<command>". This causes the quotes added by TC to always be stripped off again and for the command on TC's command line to be executed exactly as when entered in a command prompt window.
I am not sure though if parameter /S was a supported parameter for cmd.exe from the very beginning. It existed early on for sure, but whether it existed as a parameter since the first cmd.exe version, I don't know.
I don't know what currently happens when running TC on Windows 95/98 and cmd.exe is not available. TC should not add quotes when using command.com because then commands wouldn't run at all. Parameter /S and quotes around the entire command are not supported for command.com AFAIK.
There is currently also an inconsistency with the behavior when TC automatically adds "cmd.exe /C" (see here). In that case no quotes are added by TC. I think ideally quotes should be added and parameter /S should be used whenever possible in both cases:
cmd.exe /S/K "<command>"
cmd.exe /S/C "<command>"

