Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
1  
Technically, the file is cmd.exe, though it’s not really being executed; it already was. ;-) –  Synetech Jun 12 '11 at 3:57
add comment

4 Answers

up vote 5 down vote accepted

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!

share|improve this answer
add comment

Most standard "DOS" commands are built into the command shell in Windows. There isn't a dir or cd application

share|improve this answer
add comment

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:.

share|improve this answer
    
A +1 for you if you address the OP's unstated part of the question with regard to where the external utilities reside. (It's a very good answer so far, by the way.) –  Dennis Williamson Jan 6 '11 at 20:50
3  
+1 for an extensive list, but -1 for mixing MS-DOS and Windows command line shell. –  grawity Jan 7 '11 at 6:17
    
@Dennis: You're welcome, and thank you for reminding that. @grawity: Can you please drop a few lines to clarify the confusion? I really don't see what part of my answer is lacking. –  Mehper C. Palavuzlar Jan 7 '11 at 7:44
4  
I'm not sure if this is exactly what grawity is aluding to but command.com was the name of the native DOS command-line shell. It was included in Windows 9x as that generation of windows was dependent upon DOS for certain services. Windows NT is not at all dependent upon DOS and so command.com is not present, the shell in NT is a native windows application called cmd.exe located in %WINDIR%\System32 –  Crippledsmurf Jan 7 '11 at 8:35
add comment

For additional reference, here is a nice website that fairly good list of commands available for cmd.exe:

http://ss64.com/nt/

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.