MS-DOS 6.22: Run Commands on Write-Protected Disks
This article explains the internal behavior of MS-DOS 6.22 when loading and executing commands from a write-protected floppy diskette. It covers the operating system's execution pipeline, read-only media handling at the BIOS and DOS kernel level, batch file execution, and the specific conditions that trigger critical system errors during runtime.
Executable Loading Mechanism
MS-DOS 6.22 executes programs using the MS-DOS EXEC function
(Interrupt 21h, Function 4Bh). When a user enters a command pointing to
an executable file (.COM or .EXE) located on a
write-protected floppy, the operating system only requires read
permissions to run the binary.
The execution process follows these specific steps:
- File Opening:
COMMAND.COMor the calling process opens the target file using read-only access mode (Access Code 00h). Because no write handle is requested, the operating system does not check the medium's write permissions at this stage. - Memory Allocation: MS-DOS allocates a memory segment (Program Segment Prefix or PSP) in conventional memory using Interrupt 21h, Function 48h.
- Reading into Memory: The DOS kernel reads the program header and code/data segments into RAM using disk read functions.
- Relocation and Execution: For
.EXEfiles, MS-DOS parses the relocation table to patch memory addresses, sets up the segment registers (CS,DS,ES,SS), and transfers instruction control directly to the program's entry point.
Because the entire loading pipeline relies exclusively on read operations, the physical write-protection of the disk does not interfere with loading the executable into memory.
Hardware and BIOS Interaction
Physical write protection on a 3.5-inch or 5.25-inch diskette is detected mechanically or optically by the floppy disk drive hardware. The drive signals the floppy disk controller (FDC) that the medium is write-protected.
During command execution:
- The DOS kernel translates file read requests into INT 13h, Function 02h (Read Sectors) calls directed to the ROM BIOS.
- The BIOS executes the read command via the floppy controller without checking the write-protection state, as reading sectors never compromises media protection.
- The floppy drive hardware never asserts an error during read operations, allowing the binary to load cleanly.
Batch Files and Command Processing
For batch files (.BAT), COMMAND.COM reads
the file sequentially line by line. The command interpreter opens the
file with read-only access, reads a single command, closes or moves the
file pointer, and processes the statement. As long as the commands
within the batch file do not redirect standard output to the floppy
drive (e.g., DIR > A:\OUT.TXT) or attempt file
modifications, the batch script executes without failure.
Internal commands resident in memory (such as DIR,
CLS, VER, and TYPE) run without
any interaction with the write-protected floppy unless explicitly
instructed to read from or write to the drive.
Runtime Limitations and Critical Errors
While loading and executing a program succeeds, operational failure occurs if the running program attempts disk-write activity on the floppy:
- Temporary Files: Programs that automatically generate scratch files, swap files, or temporary databases in their working directory will fail if the working directory is set to the write-protected drive.
- Self-Modifying Files: Some MS-DOS utilities and games attempt to write configuration settings, high scores, or internal state data directly into the executable file itself.
- Critical Error Handler: Any attempted write invokes
INT 13h, Function 03h (Write Sectors), causing the floppy disk
controller to report a write-protection fault to the BIOS. The BIOS
passes error code
03h(Write-protect error) back to MS-DOS. - The "Abort, Retry, Fail" Prompt: The DOS kernel
intercepts this write failure and triggers the Critical Error Handler
(Interrupt 24h), presenting the standard prompt:
Write protect error writing drive A: Abort, Retry, Fail?
To reliably run software from a write-protected disk in MS-DOS 6.22,
environment variables such as TEMP and TMP
must point to a writable medium (such as a hard drive
C:\TEMP or a RAMDRIVE.SYS virtual disk), and
the current working directory should be set to a writable volume if the
application defaults to saving state data locally.