List of commands by purpose - DOS/Command Prompt Reference
Introduces commands that can be used in MS-DOS Prompt, Command Prompt, or batch files based on their purposes.
For command list in alphabetical order, please see the top page of ‘DOS/Command Prompt Reference’.
To operate (copy/move/delete etc.) a file
There are the following commands for file operations.
| ‘<’ (input redirection) | Reads the content from a file when the command prompts for input. |
|---|---|
| ‘>’ (output redirection) | Writes the output generated by the command execution to a file. |
| ‘>>’ (append redirection) | Appends the output generated by the command execution to the end of the file. |
| Attrib | Changes the attributes of one or more files. |
| Comp | [Windows XP? or later] Compares two or more files and outputs the differences on the screen. |
| Copy | Copies one or more files. |
| Del, Erase | Deletes one or more files. |
| Expand | [MS-DOS 5.0 or later/Windows XP? or later] Extracts compressed files in LZ77 format or CAB format (XP and later). |
| Fc | Compares two files or one-to-many files and outputs the differences on the screen. |
| Icacls | [Windows Vista or later] Displays or modifies the Access Control List (ACL) of a file. |
| Mklink | [Windows Vista or later] Creates symbolic links or hard links. |
| More command | Outputs the contents of a text file, dividing them to fit one screen at a time. |
| Move | Moves one or more files. |
| Openfiles | [Windows XP or later] You can check and disconnect remotely opened files. |
| Prints the contents of a text file using the specified device. | |
| Recover | [MS-DOS 5.0 or earlier?/Windows NT series?/2000, XP or later] Attempts to recover files from the disk. |
| Ren, Rename | Renames a file or directory. |
| Replace | Replaces specific files within the target directory with another file. |
| Robocopy | Copies files based on specified conditions. It supports filtering by file date and attributes, and also accommodates options specified in log files or command files (job files). |
| Takeown | [Windows Vista or later] Sets the owner of a file or directory to the current user. |
| Type | Outputs the contents of a text file. |
| Xcopy | Copies one or more files. It can also copy entire directories. |
To list files / To execute a command for each files
To display a list of files in a directory or execute the same command on files within a directory, you primarily use the following commands.
| Dir | Displays a list of files in the directory. |
|---|---|
| For | Executes a command on all files/directories that match the specified conditions. |
| Forfiles | [Windows Vista? or later] Executes a command on all files/directories that match the specified conditions. |
| Tree | Displays a tree-like structure of subdirectories and files within a directory. |
To change the working directory / To copy/move/delete the directory
There are the following commands for directory operations.
| ‘<drive-letter>:’ | Changes (moves) the operating drive. (You can execute it directly, such as ‘C:’). |
| Cd, Chdir | Changes the current working directory. |
|---|---|
| Deltree | [MS-DOS, Windows 95/98/Me] Deletes a directory, even if it is not empty. |
| Icacls | [Windows Vista or later] Displays or modifies the Access Control List (ACL) of a directory. |
| If | You can check the existence of a directory. ([MS-DOS, Windows 95/98/Me] You can perform existence checking using NUL.) |
| Md, Mkdir | Creates a directory. |
| Mklink | [Windows Vista or later] Creates a symbolic link / hard link / junction point. |
| Move | Moves one or more files/directories. |
| Pushd | [Windows NT series] Changes the current working directory. This change can be reversed using Popd. |
| Ren, Rename | Renames a file or directory. |
| Rd, Rmdir | Deletes a directory. [Windows NT series/XP or later only] Deletes even if it is not empty. |
| Robocopy | [Windows Vista or later] Copies files within a directory. To copy entire directories, several options need to be specified, allowing for detailed control. |
| Subst | Creates a virtual drive with the specified directory as the root directory. |
| Xcopy | Copies one or more files. It can also copy entire directories. |
To show/operate the drive or the volume
There are the following commands for drive and volume operations.
| ‘<drive-letter>:’ | Changes (moves) the operating drive. (You can execute it directly, such as ‘C:’). |
| Chkdsk | Checks for errors on the specified drive. |
|---|---|
| Diskcomp | [MS-DOS, and Windows NT series up to Windows 8.1] Compares two floppy disks. |
| Diskcopy | [MS-DOS, and Windows NT series up to Windows 8.1] Copies the floppy disk to the another disk. |
| Format | Initializes (formats) the specified disk drive. |
| Fdisk | [MS-DOS, Windows 95/98/Me] Launches the disk management utility. |
| Label | Displays or changes the volume label and serial number of a disk. |
| Mountvol | [Windows NT series] Displays the currently mounted volumes on the system and performs mounting or dismounting operations. |
| Recover | [MS-DOS 5.0 or earlier?/Windows NT series?/2000, XP or later] Attempts to recover files from the disk. |
| Scandisk | [MS-DOS, Windows 95/98/Me] Checks for errors on the specified drive. |
| Subst | Creates a virtual drive with the specified directory as the root directory. |
| Vol | Displays the volume label and serial number of a disk. |
To use texts/strings
There are the following commands for processing text (strings) in the prompt.
| ‘<’ (input redirection) | Reads the content from a file when the command prompts for input. |
|---|---|
| ‘>’ (output redirection) | Writes the output generated by the command execution to a file. |
| ‘>>’ (append redirection) | Appends the output generated by the command execution to the end of the file. |
| % (percent) | Expands environment variables and uses their content as text. |
| ! (exclamation mark) | [Windows NT series] [Extensions] Uses delayed environment variable expansion to expand environment variables and uses their content as text. |
| ^ (caret) | [Windows NT series] It is used when you want to use special characters such as redirection symbols as ordinary characters. |
| Clip | [Windows Vista or later] Copies the input the Clip program receives to the clipboard. |
| Echo | Displays (outputs) text. |
| Find | Searches for a specified string in a file and outputs the lines where it is found, among other information. |
| Findstr | Searches for a specified string in a file and outputs the lines where it is found, among other information. It allows for more detailed search options compared to Find. |
| For | [Windows NT series] [Extensions] Parses and separates text from arguments, file contents, or command output using the ‘/F’ option. |
| If | 文字列の比較を行うことができます。 |
| Set | [Windows NT series] [Extensions] The ‘/A’ option is used for numerical calculations. Additionally, the ‘/P’ option sets input from the prompt into environment variables. |
| Sort | Sorts the input text and outputs it. |
To configure the prompt
There are the following commands for making configuration changes to the screen or environment in the prompt or batch program sessions.
| ‘<drive-letter>:’ | Changes (moves) the operating drive. (You can execute it directly, such as ‘C:’). |
| Adddrv | [MS-DOS, Windows 95/98/Me] Loads and makes a device available for use in the current session. |
|---|---|
| Cls | Clears the display on the screen. |
| Cd, Chdir | Changes the current working directory. |
| Chcp | Switches the code page (language setting, character encoding). |
| Color | [Windows NT series] Sets the colors on the screen. |
| Deldrv | [MS-DOS, Windows 95/98/Me] Releases the device loaded in the current session. |
| Doskey | Changes or extends the input method on the prompt. |
| Echo | Toggles the echo functionality (switching the display of ‘C:\>’ and similar prompts) by specifying ‘ON’ or ‘OFF’. |
| Exit | Exits the Command Interpreter (prompt). |
| Help | Displays the help for various commands. |
| Mode | Configures settings for parallel ports, screen, etc., used in DOS/command prompt, including parameters such as baud rate and code page. |
| Path | Displays or modifies the PATH environment variable. |
| Popd | [Windows NT series] Reverts the changes made to the current working directory using the ‘pushd’ command. |
| Prompt | Modifies the prompt display. |
| Pushd | [Windows NT series] Changes the current working directory. This change can be reversed using Popd. |
| Set | Displays or modifies environment variables. |
| Setver | [MS-DOS, Windows 95/98/Me] Manages version tables for MS-DOS programs. |
| Title | [Windows NT series] Changes the title of the prompt window. |
To display/configure the system settings/state
There are the following commands to display or modify system-wide settings and the system's status.
| Assoc | [Windows NT series?/XP or later] Displays or modifies file extension associations. |
|---|---|
| Break | [MS-DOS, Windows 95/98/Me] Modifies whether interrupting with Ctrl+C is allowed during file operations. |
| Date | Changes the system date. |
| Ftype | [Windows NT series?/XP or later] Displays or modifies the file types used for file associations. |
| Hostname | [Windows NT series?] Displays the hostname of the local computer. |
| Lh, Loadhigh | [MS-DOS, Windows 95/98/Me] Loads and executes a resident program into upper memory. |
| Mem | [MS-DOS, Windows 95/98/Me] Displays the current status of memory usage, including conventional memory and upper memory. |
| Mountvol | [Windows NT series] Displays currently mounted volumes on the system and performs mounting or unmounting operations. |
| Reg | [Windows NT series/XP or later] Performs registry operations via the command line. |
| Runas | [Windows 2000 or later] Runs a program as a different user. |
| Setx | [Windows Vista or later] Adds or modifies values in user-specific or system-wide environment variable settings. |
| Shutdown | [Windows XP or later] Performs actions such as shutting down or restarting the system. |
| Sys | [MS-DOS, Windows 95/98/Me] Transfers (copies) necessary files to the system drive. |
| Systeminfo | [Windows NT series] Displays information about the computer. |
| Tasklist | [Windows XP Professional/Vista or later] Displays a list of programs running on the computer along with their information. |
| Taskkill | [Windows XP Professional/Vista or later] Terminates a program running on the computer. |
| Time | Changes the system time. |
| Tskill | [Windows XP or later] Terminates a program running on the computer. |
| Tzutil | [Windows Vista? or later] Displays or modifies the time zone settings. |
| Ver | Displays the version of MS-DOS/Windows. |
| Verify | Displays or sets whether file verification (checking if files are correctly written) is enabled. |
| Whoami | [Windows Vista or later] Outputs information such as the username, group name, and permissions based on the current session. |
To control the batch program
To execute programs or change the execution order in a batch file or similar environment, use the following commands.
| ‘<exec-file>’ | Executes a command or program (directly run ‘cmd.exe’, for example). |
| | (pipe) | Redirects the output of one command as the input for another command. |
|---|---|
| @ (at mark) | Suppresses displaying commands on the screen even when Echo is ON. |
| : (colon) | Defines a label. |
| % (percent) | Expands environment variables and uses their content as text. |
| ! (exclamation mark) | [Windows NT series] [Extensions] Uses delayed environment variable expansion to expand environment variables and uses their content as text. |
| & (ampersand) | [Windows NT series] Executes two commands in sequence on a single line. |
| || (logical OR) | [Windows NT series] Executes the command specified on the left of ‘||’, and if it fails, executes the command specified on the right. |
| && (logical AND) | [Windows NT series] Execute the command specified on the left of ‘&&’, and if it succeeds, execute the command specified on the right. |
| ‘( )’ (parentheses characters) | [Windows NT series] Groups commands together, commonly used with ‘For’ or ‘If’ statements. |
| Choice | [MS-DOS, Windows 95/98/Me, Windows Vista or later] Displays options and prompt the user for a choice. |
| Call | Executes a batch program without terminating the calling batch program. [Windows NT series] [Extensions] Temporarily transfers control to another part within the same batch program, similar to a function call. |
| Cmd | [Windows NT series] Launches the command interpreter (the Command Prompt). |
| Command | Launch the command interpreter (the MS-DOS Prompt). |
| Echo | Displays (outputs) text. Or toggles the echo functionality (switching the display of ‘C:\>’ and similar prompts) by specifying ‘ON’ or ‘OFF’. |
| Endlocal | [Windows NT series] Ends the localization of environment variables. |
| Exit | Exits the command interpreter (prompt). If no options are specified, it will exit not only batch programs but also the prompt.[Windows NT series] [Extensions] ‘Call’で呼び出したラベル内での処理を終了します。 |
| Goto | Jumps to the specified label. |
| If | Performs a conditional test, and if the condition is true, executes the specified command. |
| Pause | Pauses execution and waits for user input. |
| Rem | Ignores the text following on the same line. It is used for commenting. |
| Set | Displays or modifies environment variables. |
| Setlocal | [Windows NT series] Localizes environment variables. [Extensions] Sets the ON/OFF status of Extensions or the delayed environment variable expansion feature. |
| Shift | Shifts the contents of batch program parameters (arguments). |
| Start command | [Windows 95/98/Me/NT/XP or later] Executes a program or open a file. It can also specify whether to wait for termination, even for GUI programs. |
| Timeout | [Windows Vista or later] Sets up a waiting state with a timeout for input. |