Documentation .CMD .BAT .BTM

Apr 2, 2011
North Carolina, USA
The help pages for all three are the same. Be great if they could be different and provide examples of what extension should work in what situations.

Charles Dye

Super Moderator
Staff member
May 20, 2008
Albuquerque, NM
BTM files cannot modify themselves dynamically, a foul and hideous technique I haven't seen in years.

BTM files run faster. Usually the difference is invisible, but over a network (login scripts!) it can be dramatic.
May 26, 2008
My preference is to name batch files with a BTM extension only if they don't work in cmd.exe. (That is, only if they are using TCC specific functions or syntax.)
For batch files that work in cmd.exe I use the CMD extension. I never use BAT any more.

It would be kind of cool if I could figure out how to get TCC to execute all *.cmd batch files using cmd.exe directly (to avoid the instances where TCC isn't fully compatible with cmd syntax). Started a thread on this a while back but was never able to get it to work as I expected.
Apr 2, 2011
North Carolina, USA

.BTM (load entire file in memory before executing, hence run quicker, can NOT modify dynamically,
.BAT (loads and runs file line by line, hence slower then .BTM, can modify dynamically,
.CMD (same as .BAT, extension is same as MSDos's CMD.EXE)

Anything else?
Nov 2, 2008
EXTPROC only works in CMD files. I make heavy use of extproc batches, where the external processor is a rexx script (usu weave.rex).

/* REXX */ only works in CMD files.
Apr 2, 2011
North Carolina, USA
Stupid me but EXTPROC is ? I guess PROC is Procedure so EXT is either EXIT or EXTEERNAL...?
May 26, 2008
Interesting... I didn't know about EXTPROC before. But it doesn't seem to be working for me in v17.

test.cmd contains:
EXTPROC C:\Windows\System32\cmd.exe

dir c:\

But when I run from TCC, I get:
C:\> test.cmd
TCC: Unknown command "C:\Windows\System32\cmd.exeC:\test.cmd"

There is no space between cmd.exe and C:\test.cmd. (And yeah, I'm aware that cmd.exe doesn't ignore EXTPROC....)
Nov 2, 2008
EXTPROC and /* */ is inherited from OS/2 cmd.exe, by way of 4os2 to 4nt.

You can write command processors in REXX, and then have the data file in a .CMD file. REXX scripts work fine as extproc command processors. I have a kind of home grown WEAVE (see Donald Knuth), which processes .CMD files by weave, and writes nicely synched sets of files, all without a hint of comment, because in literate programming, such as by DK and myself, you write the process as a paper, and syphon out stuff to compile/run.
Nov 2, 2008
This is a sample batch extproc and .cmd file, the sort of thing i make a good deal of use of.

Suppose you have a REXX script like SIMPCALC.REX

/* REXX */
numeric digits 20
parse arg infile
call stream infile, 'c', 'open read'
outfile = "temp.txt" ; call stream outfile, 'c', 'open write replace'
do while lines(infile)
  incard = linein(infile)
  parse var incard 1 cx 2 tail
    when cx = ';' then break
    when cx = '=' then interpret 'outcard='tail
    otherwise ; outcard = tail ; end
call lineout outfile, outcard
call stream infile, 'c', 'close'
call stream outfile, 'c', 'close'

You then can write a text file into a CMD file, and have rexx produce the output

EXTPROC simpcalc.rex
; goto :eof
;  Inline calculator
= 0.3048*3
= o.3048*66

This is an External processor simpcalc.rex, and one of its command files. Using a slightly greater parsing process, one can get it to print out fully formatted tables, for different measuring systems. The tables in actually reside in an EXTPROC batch, where

constants ko

produces this table in the measurement system 'ko', and a different command "constants mks" will produce the same in MKS.

The expanded extproc command is regina.exe systemx.rex constants.cmd ko, the systemx.rex by extproc, and regina.exe by set .rex=regina.exe
Sep 11, 2009
Portland, Or.
I was searching for a possible way to add the filetype of REX (or REXX) to the existing executables, like; EXE, BAT, CMD .. etc..
I added both REX & REXX to PATHEXT, but just entering "TEST" (for my simple TEST.REX file), at the command prompt, does not execute
the TEST.REX. Entering "TEST.REX" does execute it.

I'd like to add .rex & .rexx as extensions that do not need to be typed with the filename, and have ASSOC & FTYPE handle my rex
processor without specifying the extension, but haven't found it.

I found the above post about a CMD file having /* ... */ in the first line calling the rex processor so I renamed that my TEST.REX file to TRY.CMD
but when I entered "TRY" (without the extension), it *crashed* TakeCommand ! ! ..

Bug? Misunderstanding? Or? I'm still on R11 of TC.

Is there a way to add .rex to the list of executables that DON'T need the extension explicitly added?

-- update.. Don't know why I had that crash.. Brought TC back up and the "/*...*/" bit works now ? .. sigh.... stuff happens
Last edited:
Nov 2, 2008
None of JP processors have rexx bundled with them, but there are two excellent ones out there: Regina.rexx (which is classic rexx), and OORexx (object orientated rexx). You have to install one of these, or at least extract the various executables. Lua seems to be the first bundled processor, but you wonder why they don't just provide a lua interface, eg (tcc.wildspec) and let people download their own lua?

You need at a minimum, regina.dll and regina.exe, but there are other DLLs worth getting, such as Patrick McPhee's W32UTIL and SYSUTILS (now in regina). Documentation is in PDF, but quite servicable. (I use a windows IPF viewer, and the DOSREXX.INF from PC-DOS 7 for my needs.

I use regina rexx. Once this is installed, and 'assoc .rex' gives a decent answer, you can indeed do things like add .REX to the PATHEXT environment, or `set .rex=regina.exe`. It even works (gosh), if you put .REX in the string built into cmd.exe. But you have to provide your own rexx processor!

EXTPROC works with rexx scripts. The example in the 4NT.HLP file suggests that there is an EXE file processing it, but you can use a grotty REXX script to do it. This means, for example, that ye can write up a line-processing calculator, and have nice formatted documents with calculations from a rough list of names and equations.

REXX was IBM's glue language, and all command processors were supposed to be able to run batch files written in REXX. This is why you see .CMD and .BAT files designed to run REXX if they start /*. It's a nice language, but don't expect to do anything stupid like calculating the array suffix in place (ie T =P.(X-1) does not work, but Y=X-1; T=P.Y gives the right answer.)
Last edited:
Nov 2, 2008
Re adding .REX to the PATHEXT. Works under tcc 16/17/18 under Windows 6.3 (8.1 by the box),

Have not tried EXTPROC in this, i mainly use 4NT/TCMD 8.01 on Windows 2000 on the main iron.
  1. Download and install Regina Rexx or OOREXX.
  2. Install. Associate .REX to regina.exe (or rexx.exe)
  3. Edit PATHEXT to include .REX
  4. New cmd.exe sessions will then run .rexx
  • Alternately, `set .rexx=regina.rex` works in 4NT but not CMD
Similar threads
Thread starter Title Forum Replies Date
M Oracle batch OPatch.bat.bat not working in TCC but correctly in CMD Support 5
S How to? Deinstalling TC/reinstating execution of bat files by cmd in Win7 Support 31
E How to? use Executable Extensions: .bat and .cmd Support 8
C .bat files works in cmd.exe, not in TCMD Support 6
CWBillow TCC and CMD / BAT files Support 3
C .CMD .vs. .BAT Support 3
T WAD CMD incompatibility Support 14
sully9 How to? Unexpected %DATE% CMD variable format (vs DATE /T format) in CMDebug Support 1
L FTYPE in TCC, less quirky than in cmd.exe Support 3
Peter Murschall Single-line Do-CMD is a bit uncooperative. Support 6
FreezerBurnt Help making a CMD and TCC compatible batch file Support 7
T Date format date different from cmd Support 7
D Differences between TCC and CMD with COPY /b Support 4
E TCC/CMD difference Support 5
D How to? Pass OpenHere Folder to CMD? Support 6
R Difference between TCC and CMD: variable names with hyphens Support 4
M WAD "Pictures" directory is empty in TCC but not in CMD or Explorer Support 4
rps Cmd history recall Support 4
rps Documentation TITLE cmd docs Support 0
Joe Caverly PUSHD with UNC path in CMD.EXE Support 2
W Starting program for word to pdf conversion (difference cmd and tcc) Support 13
Joe Caverly Using this CMD technique from TCC Support 17
W If command - different with CMD Support 6
I how to make TCC default/replace cmd.exe? Support 9
R FOR usage error from TCC but not from CMD Support 16
I findstr works in cmd but not in tcc Support 5
D Pasting Unicode data has different behavior on TCC and CMD Support 2
M Command line parsing differences between cmd.exe and TCC Support 6
Joe Caverly Works with CMD.EXE, no output with TCC.EXE Support 7
Joe Caverly tcommand(cmd) Support 13
L WAD ECHO. expansion of non-existent env-vars differs from CMD.exe Support 6
Joe Caverly "Functions" in cmd.exe batch files Support 6
Joe Caverly Works in debugger, not from cmd line Support 1
K CMD, TCC, VisualStudio 2017, VcVars* differences Support 1
D Does TCC improve CMD's implementation of ECHO? Support 6
P Labels in batch files: TCC vs CMD.exe Support 9
Patulus Yet another thread on CMD compatibility Support 16
A Fixed (CMD compat) START /D fails to recognize the switch option. Support 3
Joe Caverly CMD.EXE and filename(1).ext Support 3
H DOS CMD Sort+Add Sequence+Remove Sequence number Support 12
T WAD Difference between TCC and CMD in handling multi-command lines Support 6
C Nested IF syntax — TCC behaving differently to CMD Support 12
T CMD incompatibility Support 14
V Network share slowness vs CMD? Support 19
P Fixed Rexx .cmd files no longer work in TCC 20 Support 3
TT's Help! Uninstalling TCC did not restore cmd.exe as Win10 default batch file processor. Support 4
R How to? Display text same as in CMD Support 14
D Tab completion differences with cmd.exe Support 3
deleyd Fixed Behavior different than CMD Support 1
vefatica START, CMD vs. TCC Support 0

Similar threads