I'm wondering how modern batch files (.bat) are different from MS-DOS .bat files?

There are some commands that feel more "modern" and don't seem like something you'd see in an older system. How do the commands in modern batch files (winXP-win7, maybe win8/10) compare to DOS batch files?

  • 1
    I'm not sure what you're asking here. Windows runs old DOS batch files quite happily. Are you asking more about Powershell? What do you mean by feeling more modern?
    – Chenmunka
    Commented Dec 8, 2016 at 15:02
  • I'm wondering if anything has changed from old batch files to modern batch files. Have any new commands surfaced? Have any syntax changed?
    – Jared
    Commented Dec 8, 2016 at 15:56

2 Answers 2


In MS-DOS and the variants of Windows that ran on top of it (3.x, 95, 98, Millenium) batch files would be interpreted by the 16-bit command line interpreter COMMAND.COM. In the NT kernel versions of Windows (NT, 2000, XP, Vista, 7, 8, 10 and server variants) they are interpreted by the 32-bit command line interpreter CMD.EXE. As it happens CMD.EXE supports the old MS-DOS internal commands (COPY, RENAME and so forth) and adds some new ones (POPD, PUSHD and others). So old MS-DOS batch files will by and large work today, modern ones would only work in MS-DOS if they use commands that existed in MS-DOS, don't use long filenames, don't use external programs like nslookup that didn't exist back then, and so forth.

Here's a table listing them and when they appeared, up to Windows 8.

  • 4
    It's also important to note that 16-bit .COM programs (e.g. EDIT.COM) that existed in (and afaik before) Windows 9x (I think in the \Windows\command folder) do not exist in x64 versions of Windows; they only exist in 32-bit and may not in future (post Win10) versions.
    – wizzwizz4
    Commented Dec 8, 2016 at 20:51
  • Ah yes. The only thing I remember breaking old batch files is the choice command disappeared for awhile. But it was always external so if you want them to work, all you need to do is write it again.
    – Joshua
    Commented Apr 26, 2020 at 18:28

As Alan B wrote, the .bat interpreter is completely different: command.com in MS-DOS, cmd.exe in modern Windows versions.

A related question on Stack Overflow gives a good insight, especially this answer. I won't duplicate it here, just a snippet:

Here is a list of cmd.exe features that are not supported by command.com:

Long filenames (exceeding the 8.3 format)
Command history
Tab completion
Escape character: ^ (Use for: \ & | > < ^)
Directory stack: PUSHD/POPD
Integer arithmetic: SET /A i+=1
Search/Replace/Substring: SET %varname:expression%
Command substitution: FOR /F (existed before, has been enhanced)
Functions: CALL :label

I'd add from personal experience the FOR command, which is essential to pretty much any batch file to process, well, batches :-) was introduced in MS-DOS 5.0 but was quite limited back then. Command extensions and substitution of variables came with CMD.EXE.

Just for the fun: if you run for /? in a windows 10 command prompt, the first lines of text are 100% identical to the ones in MS-DOS 5.0 (which was released in 1991). This is what I call backward compatibility!

Here are allowed batch commands in MS-DOS 6.22 (as taken directly from MS-DOS 6.22 HELP command). They still work as intended as of Windows 10:

Call    Calls one batch program from another without causing the first batch program to stop. 
If      Performs conditional processing in batch programs. If the condition specified by an IF command is true, MS-DOS carries out the command that follows the condition. If the condition is false, MS-DOS ignores the command.
Choice  Permits the user to make a choice in a batch program. Displays a specified prompt and pauses for the user to choose from among a specified set of keys.
Pause   Suspends processing of a batch program and displays a message that prompts the user to press any key to continue.
Echo    Displays or hide the text in batch programs when the program is running. Also indicates whether the command-echoing feature is on or off. You can also use the echo command to display a message.
Rem     Enables you to include comments in a batch file.
For     Runs a specified command for each file in a set of files.
Shift   Changes the position of replaceable paramaters in a batch program.
Goto    Directs MS-DOS to a line in a batch program that is marked by a label you specify.

The following commands have command extensions in CMD.EXE (but remain backward compatible)

Call    CALL command now accepts labels as the target of the CALL.
If      IF [/I] string1 compare-op string2 command (compare-op can be EQU, NEQ, LSS, LEQ, GTR, GEQ)
        IF CMDEXTVERSION number command (not really sure what it does)
        IF DEFINED variable command (returns true if the environment variable is defined)
Choice  Adds a few switches such as 
        /CS Enables case-sensitive choices to be selected.
            By default, the utility is case-insensitive.
        /D  Specifies the default choice after nnnn seconds.
        /M  Specifies the message to be displayed before the prompt. (in MS-DOS, no switch is required for this)
For     As stated above, this is a command that has been improved a lot. Too many extensions to print here :) Check http://ss64.com/nt/cmd.html 
Goto    GOTO command now accepts a target label of :EOF which transfers control to the end of the current batch script file.

(Compiled from running help in a windows 10 command prompt)

  • 1
    Command history was added (at least in MS-DOS 6.x) by loading DOSKEY. It was also available directly in some third-party shells (I think 4DOS had it, for example).
    – user
    Commented Dec 9, 2016 at 9:59
  • Ah, right, but it is an external command (also introduced in MS-DOS 5.0). If we extend the question to external commands, there will be much more differences. I miss debug.exe :-)
    – Cebe
    Commented Dec 9, 2016 at 10:05
  • True, but DOSKEY was largely irrelevant in batch files anyway, so no big loss there. :-)
    – user
    Commented Dec 9, 2016 at 10:26
  • 2
    EDLIN is gone too, but COPY CON myfile.txt still works!
    – Alan B
    Commented Dec 9, 2016 at 15:34
  • In addition, double quotes have no special meaning in IF in the MS-DOS/Windows 3.x, so if /I==%1 echo 1 is fine but in cmd.exe (NT code base - win5x or higher) it would need to be written as IF "/I"=="%1" echo 1. This change makes newer batch files more flexible. Although it is not mandatory to quote the strings in the IF statement it is better to double quote strings in case it has special characters eg. ampersand (&). The only time you would not want to do this is if the strings already contain double quotes eg set text="text with quotes"
    – Scott R
    Commented Aug 26, 2018 at 8:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .