Skip to main content

TCC and CMD Compatibility

We try to keep TCC as compatible as possible with CMD.EXE (the default Windows command processor), given the limitations and bugs in CMD, the variations in CMD in different versions of Windows, and the thousands of additional features provided by TCC. On rare occasions, you may find batch files that exploit undocumented features or bugs in CMD (or are simply badly written) that don't work in TCC. In almost all of those cases, TCC will run those batch files if you set the appropriate compatibility options.

If you want to write batch files that are compatible with CMD, you will need to:

  1. In the batch debugger, click on the Options menu and select "CMD Syntax". This will turn on some CMD compatibility flags (including to duplicate CMD bugs), and change the command syntax coloring to only recognize CMD commands.
  2. Make sure you are not using any of the extended TCC options for the CMD commands (i.e., COPY, DEL, DIR, REN, etc.).

There are two options you should set if you regularly run batch files created for CMD:

OPTION / Startup / Duplicate CMD.EXE bugs (This is the default, and tells TCC to duplicate two bugs in CMD's IF command parsing.)

OPTION / Startup / CMD.EXE delayed expansion (If you have this startup option set for your CMD environment.)

If you only run batch files created for CMD (with variable names with a preceding and trailing %), you should also set:

CMDVariables=YES

in your TCMD.INI file. WARNING: This means you may not be able to run some batch files written for TCC, which only requires a single leading % for variables. (TCC can usually determine the variable name with either only a leading % or with a trailing %, but in some instances it is not feasible to do so.)

There are also some TCC features that might on very rare occasions cause conflicts with CMD batch files:

Enable "OPTION / Startup / Search for SFNs". (Definitely not recommended unless you want some potentially unpleasant results when you're copying, moving, or deleting files, but it *is* how CMD does it.)

Disable pseudovariable expansion (OPTION / Advanced / Special Characters).

SETDOS /X279 to disable nested aliases, quoting, and include lists.

Finally, if you want CMD-style command line editing (i.e., practically none), you can remove most of the TCC command line editing features with the OPTION / Command Line dialog.