C:\>cmd-line.com

"Let's learn the Command-Line Interface!"

Windows cmd / DOS


introduction


What is Windows?

Windows is the most popular operating system on x86 PC (Personal Computer with x86 CPU). Unlike GNU Linux, Windows does not have a CLI mode that works without a GUI. But we can use the command interpreter in the GUI.

Command interpreter in Windows interface

Cmd.exe is a command interpreter in Windows. Cmd.exe is derived from COMMAND.COM - a MS-DOS interpreter. Because of this, many cmd.exe commands are compatible with MS-DOS commands.

How to run command prompt in Windows NT?

  1. Start > write command prompt or cmd.exe
  2. Start > Programs > System tools > Command prompt
  3. Start > Programs > Accessories > Command prompt
  4. Start > Run > cmd.exe

How to run MS-DOS prompt in Windows NT (only 32-bit)?

  1. Start > write command.com
  2. Start > Run > command.com

How to run MS-DOS prompt in Windows 9x?

  1. Start > Programs > MS-DOS prompt
  2. Start > Run > command.com

What is MS-DOS / PC-DOS?

MS-DOS / PC-DOS (Disk Operating System) is a text-based & single-tasking operating system for PC with x86 CPU. It was popular in the 80s and early 90s. It doesn't have GUI, so we can use DOS only in Command-Line Interface. Nowadays, DOS is practically not used as the primary operating system.

What is FreeDOS?

FreeDOS is an open-source operating system compatible with MS-DOS.

How to run DOS on modern computer?

On modern computers, we will not run the original DOS versions (MS-DOS / PC-DOS) as the plain operating system.

Ways to use DOS:

  1. emulator, e.g. DOSBox
  2. virtual machine, e.g. VirtualBox
  3. "modern DOS" - FreeDOS

DOS-based Windows vs Windows NT


class DOS DOS-based Windows Windows NT family
operating system DOS DOS / Windows 9x
graphical environment - Windows 1-3 Windows 9x
x-bit OS 16 16 16/32 32 64
x-bit programs run 16 16[1] 16/32 16/32 32/64
command interpreter COMMAND.COM COMMAND.COM
cmd.exe
PowerShell[2]
cmd.exe
PowerShell[2]
DOS programs run in real mode real / virtual mode[3] virtual mode[4] virtual machine - NTVDM -
multitasking - cooperative 16-bit - cooperative
32-bit - preemptive
preemptive
file system FAT12
FAT16
FAT16
VFAT
FAT32[5]
NTFS
file name length 8 + 3 255 255

* Windows 1-3: 1.x, 2.x, 3.x
* Windows 9x: 95, 98, Me
* DOS-based Windows: 1.x, 2.x, 3.x, 95, 98, Me
* Windows NT family: NT, 2000, XP, Vista, 7, 8, 10, Server

  1. Windows 3.1 / 3.11: there is an additional Win32s API which allows to run some 32-bit programs
  2. PowerShell: in Windows 7 and later
  3. From Windows /386 2.1, DOS programs can run in virtual mode
  4. In Windows 95/98 it is possible to run pure DOS in real mode without Windows
  5. FAT32: supported in Windows 95 OSR2 and later Win9x

cmd.exe vs COMMAND.COM vs FREECOM.COM

command interpreter cmd.exe COMMAND.COM FREECOM.COM
operating system Windows NT MS-DOS
DOS-based Windows
Windows NT 32-bit
FreeDOS
autocomplete
file name length 255 8 + 3 255

MS-DOS 6.22 vs FreeDOS 1.2

operating system MS-DOS 6.22 FreeDOS 1.2
command interpreter COMMAND.COM FREECOM.COM
supported file systems FAT12
FAT16
FAT16
VFAT
FAT32
disk size up to 2GB up to 128GB / 2TB
memory manager HIMEM
EMM386
HIMEMX
JEMM386
multi-boot
advanced power managment
release year 1994 2016
source model closed source open source (GNU GPL)

MS-DOS versions

version supported file systems HDD maximum size 5.25" floppy disk support 3.5" floppy disk support year
1.1 FAT12 360KB 1982
2.0 FAT12 10MB 360KB 1983
3.0 FAT12 32MB 360KB 1.2MB 1984
4.0 (multitasking - abandoned) FAT12 FAT16 360KB 1.2MB 1986
3.2 FAT12 32MB 360KB 1.2MB 360KB 1986
3.3 FAT12 32MB 360KB 1.2MB 360KB 1.44MB 1987
4.0 FAT12 FAT16 2GB 360KB 1.2MB 360KB 1.44MB 1988
5.0 FAT12 FAT16 2GB 360KB 1.2MB 360KB 1.44MB 2.88MB 1991
6.0 FAT12 FAT16 2GB 360KB 1.2MB 360KB 1.44MB 2.88MB 1994
6.2 FAT12 FAT16 2GB 360KB 1.2MB 360KB 1.44MB 2.88MB 1994
6.22 FAT12 FAT16 2GB 360KB 1.2MB 360KB 1.44MB 2.88MB 1994
7.0 (Windows 95, 95A) FAT12 FAT16 2GB 360KB 1.2MB 360KB 1.44MB 2.88MB 1995
7.1x (Windows 95B, 95C, 98, 98SE) FAT12 FAT16 FAT32 124.55GB 360KB 1.2MB 360KB 1.44MB 2.88MB 1996
8.0 (Windows Me) FAT12 FAT16 FAT32 124.55GB 360KB 1.2MB 360KB 1.44MB 2.88MB 2000

Windows 1.x - 3.x versions

version name minimal
MS-DOS[1]
mode[3] registry year
real standard enhanced
1.01 Windows 1.01 2.0 1985
2.03 Windows 2.03 2.0 1987
2.1 Windows/286 2.1 2.0 1988
2.1 Windows/386 2.1 2.0 1988
3.0 Windows 3.0 3.1 1990
3.1 Windows 3.1 3.3 1992
3.1 Windows for Workgroups 3.1 3.3 1992
3.11 Windows 3.11 3.3 1993
3.11 Windows for Workgroups 3.11 3.3 1993

Windows 9x versions

version name included
MS-DOS[2]
FAT32 IE DirectX year
4.0
[950]
Windows 95 7.0 1995
4.0
[950a]
Windows 95 SP1 7.0 2.0 1996
4.0
[950A]
Windows 95 OSR1 7.0 2.0 1996
4.0
[950B]
Windows 95 OSR2 7.1 3.0 2.0a 1996
4.0
[950B]
Windows 95 OSR2.1 7.1 3.0 2.0a 1997
4.0
[950C]
Windows 95 OSR2.5 7.1 4.0 5.0 1997
4.1
[1998]
Windows 98 7.1 4.01 5.2 1998
4.1
[2222A]
Windows 98 SE 7.1 5.0 6.1a 1999
4.9
[3000]
Windows Me 8.0 5.5 7.1 2000
  1. Windows 1.x - 3.x are only programs that run in DOS. They need DOS in version written above.
  2. Windows 9x are installed with DOS. They are complete operating systems.
  3. Windows real mode works in processor real mode (need 8086 CPU)
    Windows standard mode can work in processor protected and real mode (need 80286 CPU)
    Windows enhanced 386 mode can work in protected, virtual and real mode (need 80386 CPU)
    Real / Standard mode: possible run DOS program in fullscreen, but programs in background are stopped
    Enhanced mode: possible run mulitple DOS programs, in window, programs in background can work
  4. Windows 95, 98, 98SE can boot in DOS real mode without Windows system extenders (GUI, etc)

Windows NT versions

version name architecture year
IA-32
x86-32
AMD64
x86-64
other
3.1
[528]
Windows NT 3.1 Alpha, MIPS 1993
3.5
[807]
Windows NT 3.5 Alpha, MIPS, PowerPC 1994
3.51
[1057]
Windows NT 3.51 Alpha, MIPS, PowerPC 1995
4.0
[1381]
Windows NT 4.0 Alpha, MIPS, PowerPC 1996
5.0
[2195]
Windows 2000 2000
5.1
[2600]
Windows XP 2001
5.2 Windows XP 64-bit Edition IA-64 2005
5.2
[3790]
Windows Server 2003 IA-64 2003
5.2
[3790]
Windows XP Professional x64 Edition 2005
5.2
[3790]
Windows Server 2003 R2 IA-64 2005
6.0
[6002]
Windows Vista 2006
6.0
[6003]
Windows Server 2008 IA-64 2008
6.1
[7601]
Windows 7 2009
6.1
[7601]
Windows Server 2008 R2 IA-64 2009
6.2
[9200]
Windows 8 2012
6.2
[9200]
Windows Server 2012 2012
6.3
[9600]
Windows RT ARMv7 (32-bit) 2012
6.3
[9600]
Windows 8.1 2013
6.3
[9600]
Windows Server 2012 R2 2013
10.0
[10240]
Windows 10 2015
10.0
[14393]
Windows 10 2016
10.0
[14393]
Windows Server 2016 2016
10.0
[17763]
Windows 10 2018
10.0
[17763]
Windows Server 2019 2018

keyboard shortcuts


  • ctrl + alt + del - reboot the system
  • ctrl + c - cancel the current task
  • ctrl + s - stop the text

wildcard characters


  • ? - replace one character
  • * - replace many characters or none
  • examples

    dir *.exe - display all files with the extension exe

    del *.* - delete all files in current directory


partitions & drives


Sample numbering of partitions and drives

  • A - floppy disk drive no. 1
  • B - floppy disk drive no. 2
  • C - partition no. 1
  • D - partition no. 2
  • E - CD / DVD drive
  • F - removable drive

DOSBox - mounting partitions & drives


Mount directories

mount c ~/Apps - Linux

mount c c:/Apps - Windows

Mount CD-ROM drive

mount d /media -t cdrom - Linux

mount d d: -t cdrom - Windows

Mount virtual drive - iso file

imgmount d ~/DOS/WORMS.DAT -t iso - Linux

imgmount d c:/DOS/WORMS.DAT -t iso - Windows


directory structure


Windows 10 64-bit (NT 10.0)

C:
├── Program Files
├── Program Files (x86)
├── ProgramData
├── Users
└── Windows

Windows XP 32-bit (NT 5.1)

C:
├── Documents and Settings
├── Program Files
└── WINDOWS

MS-DOS 6.22

C:
├── DOS
├── COMMAND.COM
├── WINA20.386
├── CONFIG.SYS
└── AUTOEXEC.BAT

FreeDOS 1.2

C:
├── FDOS
├── AUTOEXEC.BAT
├── COMMAND.COM
├── CONFIG.SYS
├── FDCONFIG.SYS
└── KERNEL.SYS

system files


MS-DOS

Hidden system files on the startup disk
IO.SYS
system initialization code and builtin device drivers
MSDOS.SYS
contains system kernel; in Windows 95 and later DOS-based Windows, the entire kernel was moved to IO.SYS and the MS-DOS.SYS is a text configuration file
Command-line interpreter
COMMAND.COM
default command intepreter and interface for DOS; it's first program run after system boot; includes some internal commands
User configuration files
CONFIG.SYS
contains statements to configure DOS and load device drivers; the syntax is similar to that used Windows .ini files
AUTOEXEC.BAT
batch file run by the COMMAND.COM to execute commands at startup
Boot order

IO.SYS > MSDOS.SYS > CONFIG.SYS > COMMAND.COM > AUTOEXEC.BAT

Standard DOS device drivers
ANSI.SYS
ANSI console driver
EMM386.EXE
Expanded Memory Manager
HIMEM.SYS
Extended Memory Manager
RAMDRIVE.SYS
RAM disk
Standard DOS utility programs

file extensions


  • EXE (executive) - executable file
  • COM (command) - executable file; precursor of exe extension
  • BAT (batch) - plain text file with DOS commands
  • SYS (system) - system file
  • TXT (text) - plain text file
  • HLP (help)
  • DOC (document) - rich text file
  • DAT (data)
  • LIB (library)

environment variables


Win NT 5.1
cmd.exe
MS-DOS
COMMAND.COM
DOSBox
set
set VARIABLE

COMSPEC PATH BLASTER TEMP

DOSBox
C:\>set                                             
COMSPEC=Z:\COMMAND.COM                              
BLASTER=A220 I7 D1 H5 T6                            
PATH=Z:\;C:\COMMANDS;C:\CONFIG;C:\GAMES;C:\PROGRAMS;
TEMP=D:\TEMP                                        
                                                    
C:\>set blaster                                     
BLASTER=A220 I7 D1 H5 T6                            
                                                    
C:\>set BLASTER                                     
BLASTER=A220 I7 D1 H5 T6
FreeDOS
C:\>set                                                                         
CONFIG=1                                                                        
DOSDIR=C:\FDOS                                                                  
COMSPEC=C:\FDOS\BIN\COMMAND.COM                                                 
MIDI=SYNTH:1 MAP:E MODE:0                                                       
BLASTER=A220 I7 D4 H5                                                           
CTSYN=C:\DRV\CREATIVE\DOSDRV                                                    
LANG=EN                                                                         
TZ=UTC                                                                          
PATH=C:\FDOS\BIN;C:\COMMANDS;C:\PROGRAMS;C:\FDOS\LINKS                          
NLSPATH=C:\FDOS\NLS                                                             
HELPPATH=C:\FDOS\HELP                                                           
TEMP=C:\FDOS\TEMP                                                               
TMP=C:\FDOS\TEMP                                                                
DIRCMD=/P /OGN /Y                                                               
COPYCMD=/-Y                                                                     
OS_NAME=FreeDOS                                                                 
OS_VERSION=1.3-RC3                                                              
AUTOFILE=C:\FDAUTO.BAT                                                          
CFGFILE=C:\FDCONFIG.SYS                                                         

command information


Win NT 5.1
cmd.exe
MS-DOS
COMMAND.COM
DOSBox
help
<command> /?

browsing directories


Win NT 5.1
cmd.exe
MS-DOS
COMMAND.COM
DOSBox
<letter>:
dir
cd / chdir
tree

file manipulation


Win NT 5.1
cmd.exe
MS-DOS
COMMAND.COM
DOSBox
copy
diskcopy
xcopy
move
ren / rename
del / erase
deltree
undelete
md / mkdir
rd / rmdir

reading files


Win NT 5.1
cmd.exe
MS-DOS
COMMAND.COM
DOSBox
type
more

console


Win NT 5.1
cmd.exe
MS-DOS
COMMAND.COM
FreeDOS
FREECOM.COM
DOSBox
cls
prompt
mode
alias
mode 80
mode 40
mode con cols=80
mode con cols=40
mode con lines=25
mode con lines=28
mode con lines=43
mode con lines=50

power & session


Win NT 5.1
cmd.exe
MS-DOS
COMMAND.COM
FreeDOS
FREECOM.COM
DOSBox
exit
shutdown
halt
reboot
reset

system


Win NT 5.1
cmd.exe
MS-DOS
COMMAND.COM
DOSBox
ver
date
time
path
set

file system


Win NT 5.1
cmd.exe
MS-DOS
COMMAND.COM
DOSBox
attrib
vol
label
chkdsk
fdisk
format
bootrec
mount
imgmount

memory


Win NT 5.1
cmd.exe
MS-DOS
COMMAND.COM
DOSBox
mem
lh / loadhigh

types of memory

  • conventional
  • upper (UMA - Upper Memory Area)
  • high (HMA - High Memory Area)
  • extended (XMS - eXtended Memory Specification)
  • expanded (EMS - Expanded Memory Specification)

popular extenders

  • DOS/4G
  • DOS/4GW

TSR (Terminate and Stay Resident) programs

DPMI - DOS Protected Mode Interface


processes


Win NT 5.1
cmd.exe
MS-DOS
COMMAND.COM
DOSBox
tasklist
taskkill

boot management


Win NT 10
cmd.exe
bootrec
bootsect
bcdedit

network


Win NT 5.1
cmd.exe
MS-DOS
COMMAND.COM
DOSBox
ipconfig
ping
tracert
route
netstat

text editors


Win NT 5.1
cmd.exe
MS-DOS
COMMAND.COM
DOSBox
edlin
edit

file managers


  • DOS Shell
  • Norton Commander
  • DOS Navigator

useful programs


  • MPXPlayer
  • Arachne

batch files


Windows
cmd.exe
MS-DOS
COMMAND.COM
DOSBox
batch files extension .bat .cmd .BAT .BAT
echo
pause
rem
call
choice
goto
:<label>
if
for