Extended Commands
CMD's built-in commands are a superset of the ones recognized by the old COMMAND.COM shell, and many have been extended with new features. The command extensions are enabled by default in Windows 7,Vista, and XP, although they can be disabled if necessary. Table below lists the extended commands and their added features. If the extensions cause problems for you-for example, if you have to use old batch files that do not work with the new command versions and you cannot update them-you can start CMD with the extensions disabled. I discuss this in the section "Running CMD."
Commands Modified by Command ExtensionsCommand | Features Added by Command Extensions |
---|---|
assoc | Only available with extensions enabled. |
call | call :label Argument substitution modifiers (for example, %~f1). |
cd / chdir | Option /D changes current drive. The current directory uses the directory's actual upper/lowercase. |
color | Only available with extensions enabled. |
date | Option /T prints the date without prompting for a new date. |
del / erase | Option /S displays names of files being deleted. |
endlocal | Restores EXTENSIONS and DELAYEXPANSION settings. |
for | |
ftype | Only available with extensions enabled. |
goto | goto :EOF |
if...else | /I, IF CMDEXTVERSION, IF DEFINED Comparisons such as LEQ. |
md / mkdir | Creates intermediate directories if necessary. |
prompt | $+ and $M options. |
pushd / popd | Accepts a network path and maps a drive letter. |
set | /A and /P options. The set command with a partial name displays matching names. |
setlocal | ENABLE... and DISABLE... arguments. |
shift | /n option. |
start | Starts nonexecutable files via file extensions. Uses PATHEXT expansion. Doesn't wait for Win32 commands to exit before prompting again. Uses the COMSPEC path when the command is CMD. Runs Explorer if the command is a folder name. |
time | Option /T prints the time without prompting for a new time. |
In the next few sections, some additional detail on some of the more important commands.
In this tutorial:
- The CMD Command-Line
- CMD Versus COMMAND
- Running CMD
- Opening a Command Prompt Window with Administrator Privileges
- CMD Options
- Disabling Command Extensions
- Command-Line Processing
- Console Program Input and Output
- Using the Console Window
- I/O Redirection and Pipes
- Copy and Paste in Command Prompt Windows
- Command Editing and the History List
- Name Completion
- Enabling Directory Name Completion
- Multiple Commands on One Line
- Grouping Commands with Parentheses
- Arguments, Commas, and Quotes
- Escaping Special Characters
- Configuring the CMD Program
- The Search Path
- Changing the Path
- Predefined and Virtual Environment Variables
- Setting Default Environment Variables
- Built-in Commands
- Extended Commands
- Listing Files with the Dir Command
- Paginating Long Listings
- Printing Directory Listings
- Sorting Listings
- Locating Alternate File Streams
- Setting Variables with the Set Command
- Conditional Processing with the if Command
- Scanning for Files with the for Command
- Using the for Command's Variable
- Processing Directories
- Numerical for Loop
- Getting More Information