Computing: Computer Administration

Using 4DOS as command line interpreter on FreeDOS.

Do you know, what 4DOS is? Yet another DOS operating system? Or, "some software" for (4) DOS? I don't remember if, at the time of my first PC, I ever heard of it. Nor later, when I started to play around with VMware virtual machines. It's only last year (2022) that I read about it, learning that 4DOS is not an operating system, but a command line interpreter (shell), so a replacement for COMMAND on MS-DOS, or FreeCOM on FreeDOS. If you ever wished to have a DOS shell with lots of commands that are not available with or that offer lots more options than COMMAND.COM, a nearly unlimited batch file capability, the usage of color and textual graphics, the whole making it a powerful scripting language, then you should give 4DOS a try. I myself was really amazed by this really great piece of software.

This tutorial describes the installation of 4DOS 7.50 on FreeDOS (I actually use FreeDOS 1.3 RC5). It should also work with other FreeDOS releases and other DOS operating systems. Concerning 4DOS, there is a version 8.0 (open source) available on several Internet sites. The installation of this release failed on my system with the message Bad function (error 223) as shown on the screenshot below.

4DOS on FreeDOS: Installation failure of 4DOS 8.0

Not sure that, maybe, I missed something, but if you want to avoid a possible failure of the installation, I recommend that you use version 7.50. This is the last commercial version of 4DOS before becoming open source. It has become abandonware meanwhile and you cat get it from several websites, including the FreeDOS and 4DOS download sites, WinWorld and lyx.org (service provided by Sorbonne University); no idea, why I used the files from this site...

The download archive contains the files ready for use (no installer). I saved the archive content onto a virtual floppy diskette, then on FreeDOS, I created the directory C:\4DOS and copied all files from the diskette to there.

4DOS on FreeDOS: The 4DOS 7.50 files copied to C:\4DOS

4DOS has a whole bunch of configuration settings and you can configure 4DOS using OPTION.EXE, a textual graphic configuration utility with full mouse support. However, when you try to run OPTION.EXE, you'll get the error message OPTION.EXE cannot be run manually – you must use the 4DOS OPTION command.

4DOS on FreeDOS: The 4DOS configuration utility OPTION.EXE cannot be run using COMMAND.COM

You can start 4DOS as a secondary shell by going into the C:\4DOS directory and entering 4dos. Then, in the 4DOS shell, you can run the configuration utility by entering option.

4DOS on FreeDOS: Starting the 4DOS configuration utility OPTION.EXE in a secondary 4DOS shell

As I said above the configuration utility is a textual graphics program with mouse support and there are really lots lots of settings that you can adapt according to your needs or preferences. Note, that there is a detailed context-sensitive help system available. The different configuration screens are displayed by selecting one of the items in the Configure menu. The two screenshots below show the Startup options screen: the default settings (on the left) and my actual settings (on the right).

4DOS on FreeDOS: Configuration utility  - Startup screen (Default settings)
4DOS on FreeDOS: Configuration utility - Startup screen (Custom FreeDOS settings with everything loaded into high memory)

Here is an overview of the changes that I made, not to be considered as complete and optimal (if you intend to seriously work with the 4DOS shell, you should take the time to have a look at the program's documentation concerning the different options and the meaning of the different settings):

I did not make any changes on the Display options screen (screenshot on the left). On the Edit options screen, you probably want to change the default mode from "Overstrike" to "Insert", as well as the appearance of the cursor, using a small cursor-height for "insert" and a larger one (I chose 25%; you can choose 100% if you prefer) for "overstrike" (screenshot on the right).

4DOS on FreeDOS: Configuration utility - Display screen
4DOS on FreeDOS: Configuration utility - Edit screen

The following screenshots show the Windows options screen (on the left) and the Commands options screen (on the right). I didn't make any settings changes on these screens.

4DOS on FreeDOS: Configuration utility - Windows screen
4DOS on FreeDOS: Configuration utility - Commands screen

There are two further configuration screens, called Options 1 (on the left) and Options 2 (on the right). As you can see, you have really all liberty to customize your 4DOS.

4DOS on FreeDOS: Configuration utility - Options I screen
4DOS on FreeDOS: Configuration utility - Options II screen

4DOS is really well thought through, and you can, for example, see this, if you have a look at the Exit menu items. Besides Save (to make active the new settings and also use them the next time that 4DOS is started; to be done here now), and Cancel (to quit OPTION.EXE canceling the changes that you made), there is a third possibility: Use. This option allows to use the new settings during the actual session only; when 4DOS is restarted, the options from before will apply again.

If you are serious about learning 4DOS or working with it, you probably want to run it directly on DOS, and not as a secondary shell, started by COMMAND.COM. The simplest way to do this is to add a menu entry in your FDCONFIG.SYS. The relevant lines in my FDCONFIG.SYS are as follows:
    MENU 7 - Load FreeDOS with alternate command line processor
    MENU 9 - Load FreeDOS low with some drivers (Safe Mode)
    1234568?SHELLHIGH=C:\FreeDOS\BIN\COMMAND.COM C:\FreeDOS\BIN /E:2048 /P=C:\FDAUTO.BAT
    7?SHELLHIGH=C:\4DOS\4DOS.COM C:\4DOS /P
    9?SHELL=C:\FreeDOS\BIN\COMMAND.COM C:\FreeDOS\BIN /E:1024 /P=C:\FDAUTO.BAT

In the remaining part of the tutorial, I will show some of the features of 4DOS. First, it includes, of course, the usual DOS commands, such as for example DIR to list a directory. The parameters of such commands may or may not be the same as with COMMAND.COM, also command parameters are case-sensitive, as you can see for /W on the screenshot on the left. An example of a parameter working differently as with COMMAND.COM is the /A parameter of the DIR command. With COMMAND.COM it lists all files (i.e. including hidden and system files), with 4DOS, it has the format /A:<type>, where <type> specifies what you want to list. An example is shown on the screenshot on the right: /A:D lists only directories. This screenshot also is an example of extension of COMMAND.COM with a new parameter of the DIR command: /L lists all files in lowercase.

4DOS on FreeDOS: Case-sensitivity of 4DOS command line parameters
4DOS on FreeDOS: DIR command extensions

Other example of an extension of COMMAND.COM: The 4DOS COPY command gives the possibility to specify several source files (with or without wildcards). For example, to copy FDCONFIG.SYS, FDCONFIG.BAK, FDAUTO.BAT and FDAUTO.BAK to a floppy diskette, you can run the command:
    copy fdconfig.* fdauto.* a:

4DOS also has a whole set of new commands, i.e. commands that have no equivalent with COMMAND.COM. For example, the command ESET is a line editor for environment variables. For example, to change the path to the DOS executables, you can run
    eset path
The PATH environment variable is displayed with the cursor at the first position of the path value and you can edit the displayed line, adding, deleting or modifying some characters(s).

The real power of 4DOS, however, is its batch files (note, that these have the .BTM extension). There are lots more commands available as with COMMAND.COM and thanks to real decision-making and loop commands, it's possible to write powerful scripts of all kinds. Here is a script that gives an overview of the space usage on my three FreeDOS partitions.
    for %drive in (c: d: e:) do free %drive
The screenshot shows the output of the script (that I had called dfree.btm):

4DOS on FreeDOS: Batch file examples - Partitions space usage

4DOS includes several textual graphics commands, a little bit as you find them in the Pascal CRT unit. These commands write directly to the computer's video memory (bypassing the operating system and the BIOS) and thus only work on a truly IBM-PC compatible. They do work on a MS-DOS VMware virtual machine. Here a BTM batch file that draws the axes of a coordinate-system onto the screen:
    @echo off
    cls bright white on blue
    drawhline 20 10 40 1 bright white on blue
    drawvline 2 10 19 1 bright white on blue
    scrput 21 42 bright red on blue X axis
    vscrput 3 9 bright red on blue Y axis
And here how this looks on my FreeDOS system:

4DOS on FreeDOS: Batch file examples - Testing the 4DOS graphics features

To terminate, another example concerning the DIR command. It allows a colored directory listing, where the display color of given files depend on the color definitions provided in the COLORDIR environment variable (cf. documentation for details). The following simple script (that you can easily adapt and extend...) lists the content of the current directory (wide format, and using all lowercase), displaying subdirectories in blue, executables (.exe, .com, .bat, .btm) in green, and drivers (.sys) in magenta.
    set colordir=DIRS: bright blue; exe com bat btm: bright green; sys: bright magenta
    dir /W /L
Here is the output on my FreeDOS system:

4DOS on FreeDOS: Batch file examples - Colored directory listing

If you find this text helpful, please, support me and this website by signing my guestbook.