Programming Field

Internal (built-in) commands - DOS/Command Prompt Reference

Both MS-DOS Prompt (command.com) and Command Prompt (cmd.exe) provide internal commands that offer lightweight features, functionality related to environment variables, and features for batch file processing. Internal commands can be used on the prompt almost interchangeably with other external commands (those provided as programs/executable files). However, these internal commands have some differences and considerations compared to external commands because they don't exist as standalone executable files, albeit the distinctions are relatively minor.

Internal command list

The following commands are provided as internal (built-in) commands:

* Move and Start command are available as internal commands only when used within the Command Prompt (including batch files executed in the Command Prompt). In MS-DOS Prompt, they function as external programs.

Notice for usage

  • Internal commands cannot be directly executed as standalone programs. They must be executed through command.com or cmd.exe (you can use the COMSPEC environment variable to refer to it collectively).
    • [Windows Vista or later] For example, the Mklink command is a internal command, so it can only be executed through cmd.exe.
    • However, the ‘system’ function in the Visual C++ runtime executes commands by treating its argument as parameters for the program specified in the COMSPEC environment variable. Therefore, you can directly execute commands like ‘system("type file.txt")’.
  • Internal commands, with some exceptions like file operations or date/time changes, affect the current prompt environment. For example, the Pushd command changes the current directory in that environment, but if you explicitly give ‘Pushd’ to cmd.exe and execute the command, the current directory won't be changed.
    • Conversely, by using internal commands such as those that modify environment variables in a batch file, you can set up the necessary environment for running a program.
    • Furthermore, to avoid affecting the current prompt environment with batch file processing, you can intentionally use the ‘/C’ option of command.com or cmd.exe to execute the batch file.