Where are the standard Windows prompt commands files?

If I type dir in the command line, I guess it executes a dir.exe hidden somewhere in the system. Is there such a file? Where is it?


Solution 1:

Dir is an internal command, like cd, copy, and call. This is simply a subroutine of the DOS interpreter that you're calling.

There are, however, external commands. These commonly reside in C:\Windows\ C:\Windows\System\ C:\Windows\System32 and (if you have 64-bit windows) C:\Windows\SysWOW64\

However, external commands are not limited to these locations. External commands can be called from the directory that you're working from. (in a newly started DOS shell on Windows 7, this would usually be C:\Users\YourUsername\). External commands from other directories can also be called, as long as the directory they're in are in your PATH environment variable. To see what directories are in your path, use SET PATH.

If you're going to be needing some utility from a directory, but will have to be traversing to other directories, you can add the folder of the utility to the PATH by using SET PATH=%PATH%;DriveLetter:\Utility\Path\Here\. This change only affects that DOS window.

I hope that's new and useful knowledge!

Solution 2:

dir is an internal MS-DOS command. Like the other internal commands, it is built into the file named command.com. Wikipedia has a page for the list of DOS commands, and it says:

The command interpreter for MS DOS runs when no application programs are running; after an application exits, if the memory used for the command interpreter was overwritten, MS DOS will re-load the command interpreter from disk storage. The command interpreter is usually stored in a file called "COMMAND.COM". Some commands are built-into COMMAND.COM. When the user types a line of text at the operating system command prompt, COMMAND.COM will parse the line, and attempt to match a command name to a built-in command or to the name of an excecutable program file or batch file on disk. If no match is found, an error message is printed and the command prompt is refreshed.

Resident commands varied slightly between revisions of MS DOS. Typically, the functions DIR (list directory), ERASE or DEL (erase a file or directory), COPY (copy files), DATE (display or set date), TIME (display or set time), CD (change working directory), MD (make a directory on the current disk), REN (rename a file or directory) and some others were resident in COMMAND.COM.

To make my answer complete, the following is a list of MS-DOS internal and external commands. The internal commands reside in COMMAND.COM, which loads into memory when the computer system is started; these commands do not reside on disk. The external commands are files that do reside on disk and have an extension of .COM, .EXE, or .BAT. Both command types are executed from the MS-DOS prompt.

Internal Commands:

  • BREAK
  • CALL
  • CHCP
  • CHDIR(CD)
  • CLS
  • COPY
  • CTTY
  • DATE
  • DEL(ERASE)
  • DIR
  • ECHO
  • EXIT
  • FOR
  • GOTO
  • IF
  • MKDIR(MD)
  • PATH
  • PAUSE
  • PROMPT
  • REM
  • RENAME(REN)
  • RMDIR(RD)
  • SET
  • SHIFT
  • TIME
  • TYPE
  • VER
  • VERIFY
  • VOL

External Commands:

  • APPEND.EXE
  • ASSIGN.COM
  • ATTRIB.EXE
  • BACKUP.EXE
  • CHKDSK.EXE
  • COMMAND.COM
  • COMP.EXE
  • DEBUG.EXE
  • DISKCOMP.COM
  • DISKCOPY.COM
  • DOSKEY.COM
  • DOSSHELL.COM
  • EDIT.COM
  • EDLIN.EXE
  • EMM386.EXE
  • EXE2BIN.EXE
  • EXPAND.EXE
  • FASTOPEN.EXE
  • FC.EXE
  • FDISK.EXE
  • FORMAT.COM
  • GRAFTABLE.COM
  • GRAPHICS.COM
  • HELP.EXE
  • JOIN.EXE
  • KEYB.COM
  • LABEL.EXE
  • MEM.EXE
  • MIRROR.COM
  • MODE.COM
  • MORE.COM
  • NLSFUNC.EXE
  • PRINT.EXE
  • QBASIC.EXE
  • RECOVER.EXE
  • REPLACE.EXE
  • RESTORE.EXE
  • SETVER.EXE
  • SHARE.EXE
  • SORT.EXE
  • SUBST.EXE
  • SYS.COM
  • TREE.COM
  • UNDELETE.EXE
  • UNFORMAT.COM
  • XCOPY.EXE

Reference: Microsoft Support

Nota bene: The external commands reside in C:\Windows\System32 assuming the root drive is C:.