Est. 1989 Intermediate

4DOS Batch

The batch language of JP Software's 4DOS command processor — a shareware replacement for COMMAND.COM that gave MS-DOS real block-structured conditionals, loops, string functions, and a batch debugger.

Created by Rex C. Conn and Tom Rawson (JP Software)

Paradigm Procedural, Scripting
Typing Dynamic, Weak (effectively untyped strings)
First Appeared 1989
Latest Version Version 8.00 (February 2009)

4DOS Batch is the scripting language of 4DOS, a replacement command processor for MS-DOS and PC-DOS written by Rex C. Conn and Tom Rawson and published as shareware by JP Software beginning in February 1989. Where Microsoft’s COMMAND.COM offered a batch facility that amounted to IF, GOTO, FOR, SHIFT, and little else, 4DOS added block-structured conditionals, real loops, subroutines, a library of string and system functions, local variable scoping, and an interactive debugger — all inside a resident shell small enough to run comfortably on a 640 KB machine. For a generation of DOS users, 4DOS was the difference between batch files as a list of commands to type less often and batch files as a language you could actually program in.

History and Origins

JP Software released 4DOS 2.00 on February 15, 1989. The version number started at 2.00 rather than 1.00, and the shell’s ambition was clear from the first release: it shipped with command-line editing, a recallable command history, user-defined aliases, extended wildcard matching, online help, internal variables, swapping to disk or EMS to reclaim conventional memory, per-file descriptions stored in a DESCRIPT.ION file, a command separator for putting several commands on one line, and a key stacker for feeding keystrokes to programs.

The batch language proper came into its own with version 3.00 in March 1990. That release introduced the .BTM extension — a “batch to memory” file that the shell loads and caches rather than reopening and re-seeking for every line, which JP Software promoted as a substantial speedup over .BAT files (the company’s own version notes claimed roughly two to five times faster execution for typical scripts on the hardware of the day; that figure is a vendor claim about disk-bound line-at-a-time interpretation, not an independently benchmarked result). Version 3.00 also brought the block-structured IFF conditional and the first variable functions such as %@ext and %@len. Two months later, version 3.01 added %@eval for arithmetic and %@index for substring searching, and from that point 4DOS scripts could compute rather than merely dispatch.

The product’s reach extended well beyond its own shareware registrations. Symantec licensed the shell and shipped a modified build as NDOS in the DOS side of Norton Utilities; the last such version, in Norton Utilities 8 (1994), corresponded to 4DOS 4.03. JP Software also ported the design to other platforms — 4OS2 for IBM OS/2 on June 8, 1992, and later 4NT for Windows NT, which grew out of running 4OS2 under NT’s OS/2 subsystem. 4NT was eventually renamed Take Command Console (TCC), which JP Software still sells; the batch language documented here is, in its essentials, the language TCC scripts are written in today.

Design Philosophy

4DOS was built on a single guiding constraint: be a drop-in replacement. Anything that worked under COMMAND.COM had to keep working, byte for byte, so that a user could swap the SHELL= line in CONFIG.SYS and change nothing else. Every extension was therefore additive and, where possible, expressed through syntax COMMAND.COM would never have produced — the %@name[...] function form, the IFF/ENDIFF block keywords, the .BTM extension for the enhanced file type.

The second principle was the shell as programming environment, not just a program launcher. Conn and Rawson consistently added the facilities a scripting language needs and DOS lacked: expression evaluation, string manipulation, structured control flow, subroutines with GOSUB/RETURN, variable scoping through SETLOCAL/ENDLOCAL, keyboard input via INPUT and INKEY, error trapping with ON ERROR, and — unusually for a command processor of any era — a single-step batch debugger, added in version 6.00 in 1997.

The third was respect for the machine. DOS conventional memory was a hard 640 KB ceiling shared with every application, so 4DOS could swap its resident portion to disk, EMS, XMS, or upper memory blocks, keeping only a small loader in low memory. A shell that cost the user their spreadsheet’s working set would not have survived, no matter how good its scripting was.

Key Features

Block-structured conditionals

IFF replaced the single-line IF ... GOTO idiom that made classic DOS batch files a maze of labels:

iff "%1" == "" then
   echo Usage: build.btm target
   quit 1
elseiff exist %1.obj then
   echo %1.obj is already built
else
   cl /c %1.c
endiff

Loops

DO/ENDDO provides counted loops, while/until conditions, and iteration over file sets — replacing the label-and-GOTO pattern entirely:

do i = 1 to 10
   echo Pass %i of 10
enddo

do file in *.txt
   echo Processing %file
enddo

Multi-way branching and subroutines

SWITCH/CASE/DEFAULT/ENDSWITCH handles multi-way dispatch, and GOSUB calls a labeled subroutine within the same file, returning to the call site — no separate batch file and no re-entered command processor.

Variable functions

The %@name[argument] syntax exposes a large library of built-in functions covering arithmetic (%@eval), strings (%@index, %@upper, %@lower, %@substr), files and paths (%@ext, %@len, %@filesize), disks (%@disktotal, %@diskused, %@ready), and character conversion (%@ascii, %@char). Version 7.50 (2003) added user-defined functions, so a script could register its own %@name[] alongside the built-ins.

Aliases and command grouping

Aliases turn arbitrary command sequences into new commands, with parameter substitution, and can be loaded from a file at startup. Command groups in parentheses let several commands share a single redirection or be executed conditionally as a unit.

Batch debugging

The interactive batch debugger introduced in 6.00 single-steps a .BTM file, showing the current line and letting the user inspect and modify variables mid-run — a facility with no equivalent in COMMAND.COM at any point in its history.

File descriptions

DESCRIPT.ION, present from the 1989 release, stores a plain-text description per file in the directory. Under 8.3 filenames this was genuinely useful, and 4DOS commands such as DIR, COPY, and MOVE maintain the descriptions as files move around. The format outlived 4DOS itself and is still read by file managers such as Total Commander.

Evolution

VersionDateNotable additions
2.00Feb 15, 1989Initial release: editing, history, aliases, descriptions, key stacker
2.20Jul 5, 1989Executable extensions
3.00Mar 7, 1990.BTM files, XMS swapping, IFF, variable functions
4.00Nov 1, 19914DOS.INI, colored directories, command groups, UMB support
5.00Nov 23, 1993Date/time/size ranges, compressed batch files
5.51Aug 22, 1995Long filename support, REXX in .BAT files
6.00Jul 24, 1997Batch debugger, OPTION command, extended directory searches
7.00Jun 18, 2001@file lists
7.50Feb 24, 2003User-defined functions
7.50.1Nov 13, 2006First source-available build
8.00Feb 27, 2009Final release

The arc tracks the platform underneath it. The early versions fought for memory and speed; the mid-1990s versions chased Windows 95 compatibility and long filenames; the late versions added programming conveniences for an audience that had, by then, largely moved to Windows and to JP Software’s 4NT. JP Software shipped its last commercial update, 7.50.130, in August 2004 and afterward made 4DOS available as unsupported freeware. Version 8.00, released February 27, 2009, was the last, accompanied by source under a modified MIT license — a license that forbids use in commercial products without written permission from Rex C. Conn and restricts compilation to FreeDOS, and therefore does not meet the Open Source Initiative or Free Software Foundation definitions of open source despite the source being publicly readable.

Current Relevance

4DOS itself is dormant: there has been no release since 2009, and the DOS platform it targets survives mainly in FreeDOS, emulators, and retrocomputing. Where 4DOS does still run, it is usually under FreeDOS — the one operating system the source license explicitly permits — or in DOSBox and virtual machines maintained by people preserving DOS-era software.

The language, though, did not stop. Take Command Console (TCC), the direct descendant by way of 4OS2 and 4NT, remains a commercially developed Windows shell with active releases, and it retains IFF, DO, SWITCH, GOSUB, SETLOCAL, and the %@function library. A .BTM script written in 1995 is closer to running unmodified under TCC in 2026 than most 1995 code in any language is to running today. That continuity — a scripting language surviving three operating-system generations under three product names — is the main reason 4DOS batch is worth studying rather than merely remembering.

Why It Matters

4DOS makes a case that is easy to state and was, at the time, unusual to prove: a command language can be improved without breaking compatibility. Microsoft’s own batch language changed very little between MS-DOS 3.3 and Windows NT’s cmd.exe, and the gaps 4DOS filled in 1990 — no block conditionals, no loops beyond FOR, no arithmetic, no string functions, no subroutines, no debugger — were largely still gaps a decade later. A two-person shareware company demonstrated that the constraint was product priorities, not technical necessity.

It also stands as one of the more successful examples of the shareware model applied to system software. 4DOS was small, unglamorous, distributed on BBSes and disk collections, and good enough that Symantec licensed it for Norton Utilities and IBM users asked for an OS/2 port. Its ideas — batch files cached in memory, per-file descriptions, structured control flow in a shell, a debugger for scripts — arrived years before comparable facilities were common on the platform, and several of them, including the DESCRIPT.ION format and the TCC batch language, are still in service.

Timeline

1989
JP Software releases 4DOS 2.00 on February 15, 1989 as a shareware replacement for COMMAND.COM, written by Rex C. Conn and Tom Rawson; the first release already includes command-line editing, command history, aliases, extended wildcards, file descriptions (DESCRIPT.ION), a command separator for chaining commands, and a key stacker
1990
Version 3.00 (March 7, 1990) introduces the .BTM batch file format, which is read into memory rather than re-read from disk line by line, along with XMS swapping, the block-structured IFF conditional, and the first variable functions such as %@ext and %@len
1990
Version 3.01 (May 22, 1990) adds the %@eval arithmetic function and %@index for substring searching, giving batch files genuine expression evaluation for the first time
1991
Version 4.00 (November 1, 1991) consolidates configuration into the 4DOS.INI file and adds colored directory listings, include lists, command groups with parentheses, and support for DOS 5 upper memory blocks
1992
JP Software releases 4OS2 for IBM OS/2 on June 8, 1992, carrying the 4DOS command and batch language onto a second operating system; the OS/2 work later leads to the Windows NT port, 4NT
1993
Version 5.00 (November 23, 1993) adds date, time, and size ranges for file selection, plus compressed batch files
1994
Symantec ships NDOS, a rebranded and modified 4DOS, as part of the DOS tools in Norton Utilities 8; this last bundled version corresponds to 4DOS 4.03 and puts the shell in front of a mass retail audience
1995
Version 5.51 (August 22, 1995) adds long filename support for Windows 95 and the ability to call REXX from .BAT files
1997
Version 6.00 (July 24, 1997) adds an interactive batch file debugger, the OPTION command for interactive configuration, extended directory searches, and exclusion ranges
2001
Version 7.00 (June 18, 2001) adds @file lists, allowing commands to take their arguments from the contents of a text file
2003
Version 7.50 (February 24, 2003) adds user-defined functions, letting scripts define their own %@name[] functions alongside the built-in ones
2004
JP Software issues its final commercial update, 7.50.130, in August 2004; 4DOS is subsequently made available as unsupported freeware while the company concentrates on its Windows products
2006
Version 7.50.1 is released on November 13, 2006 as the first source-available build of 4DOS
2009
Version 8.00 is released on February 27, 2009 — the final release — with source available under a modified MIT license that restricts commercial use and limits compilation to FreeDOS, so it is not open source by OSI or FSF criteria

Notable Uses & Legacy

Norton Utilities (NDOS)

Symantec licensed 4DOS and shipped it as NDOS in the DOS tools of Norton Utilities, alongside Norton Disk Doctor and Speed Disk. The final bundled version, in Norton Utilities 8 (1994), corresponded to 4DOS 4.03, making 4DOS batch scripting available to a large commercial customer base that had never bought it directly.

FreeDOS

4DOS has long been available in FreeDOS distributions as an alternative command processor, and the 2009 source release explicitly permits compilation for FreeDOS — the only operating system the license names. It remains the practical way to run 4DOS batch files on a maintained DOS today.

DOS-era system administration

Contemporary user reports and JP Software's own documentation describe administrators using .BTM scripts for login scripts, backup and archiving jobs, and unattended workstation setup on DOS-era PC networks, where the standard batch language's lack of real loops and string handling made comparable tasks painful. Individual sites are not separately documented.

JP Software Take Command Console (TCC)

The 4DOS batch language lives on commercially in TCC — formerly 4NT — where IFF/ENDIFF, DO/ENDDO, SWITCH/CASE, GOSUB, and the %@function library survive largely intact on modern Windows, giving decades-old .BTM scripts a migration path.

Bulletin board systems and shareware distribution

4DOS was itself distributed as shareware through BBSes and disk collections, and BBS operators reportedly used its batch scripts for door-game launchers, file-area maintenance, and nightly housekeeping. The DESCRIPT.ION file description system, which carries per-file text alongside 8.3 filenames, is the most durable trace of that use: it is still read by file managers such as Total Commander.

Language Influence

Influenced By

DOS Batch COMMAND.COM

Influenced

4OS2 Take Command Console (TCC)

Running Today

Run examples using the official Docker image:

docker pull
Last updated: