Cmd command in Windows
The cmd command starts a new version of the command interpreter, Cmd.exe. If used without parameters, the cmd command will display the copyright information and the version of the operating system.
Syntax cmd command
cmd [/c|/k] [/s] [/q] [/d] [/a|/u] [/t:{ |}] [/e:{on|off}] [/f:{on|off}] [/v:{on|off}] []
Parameters
Parameter Description / c Execute the command specified by String and then stop. / k Execute the command specified by String and continue. / s Modify the handling of String after parameter / c or / k . / q Turn off the echo / d command Disable the execution of AutoRun commands. / a Internal command output format into a set or a file according to the American National Standards Institute (ANSI) standard. / u Format the internal command output to a collection or a file in Unicode format. / t: { |} Set the color for the background ( B ) and foreground ( F ). / e: on Enable command extensions. / e: off Disable command extensions. / f: on Enable completion of file names and directories. / f: off Disables the completion of file and directory names. / v: on Enable extended environment variable extension. / v: off Disable extended environment variable extension. Specify the command you want to execute. /? Show help at the command prompt.The following table lists valid hexadecimal digits that you can use as values for and
Value Color0 Black 1 Blue 2 Green 3 Mint Green 4 Red 5 Purple 6 Yellow 7 White 8 Gray 9 Light blue a light Green b Light green mint c Light red d Light purple e Light yellow f Bright whiteNote
- Use multiple commands
To use multiple commands, separate them with && and include quotation marks. For example:
" && && "
" && && "
" && && "
" && && "
- Handling quotes
If you specify / c or / k, the cmd command that handles the rest of the String and quotation marks is preserved only if all of the following conditions are met:
- You do not use / s.
- You use exactly one set of quotes.
- You do not use any special characters in quotation marks (eg: & <> () @ ^ | ).
- You use one or more whitespace characters in quotation marks.
- String in quotation marks is the name of the executable file.
If the preceding conditions are not met, String is processed by checking the first character to verify whether it is an open quotation mark. If the first character is open quotation marks, it will be removed along with the closing quotation marks. Any text after closing quotation marks is preserved.
- Execute the registry subkey
If you do not specify / d in String, Cmd.exe will search for the following registry subkey:
HKEY_LOCAL_MACHINESoftwareMicrosoftCommand ProcessorAutoRunREG_SZ HKEY_CURRENT_USERSoftwareMicrosoftCommand ProcessorAutoRunREG_EXPAND_SZ
If one or both of these registry subkeys appear, they will be executed before all other variables.
Careful:
Modifying the registry incorrectly may damage your system. Before making changes to the registry, you should back up any important data on your computer.
- Enable and disable command extensions
Command extensions are enabled by default in Windows XP. You can disable them for a particular process by using **/e:off**. You can enable or disable extensions for all **cmd** command-line options on a computer or user session by setting the following **REG_DWORD** values: **HKEY_LOCAL_MACHINESoftwareMicrosoftCommand ProcessorEnableExtensionsREG_DWORD** **HKEY_CURRENT_USERSoftwareMicrosoftCommand ProcessorEnableExtensionsREG_DWORD** Set the **REG_DWORD** value to either **0×1** (enabled) or **0×0** (disabled) in the registry by using Regedit.exe. User-specified settings take precedence over computer settings, and command-line options take precedence over registry settings.
[!CAUTION] Incorrectly editing the registry may severely damage your system. Before making changes to the registry, you should back up any valued data on the computer.
When you enable command extensions, the following commands are affected: - **assoc** - **call** - **chdir (cd)** - **color** - **del (erase)** - **endlocal** - **for** - **ftype** - **goto** - **if** - **mkdir (md)** - **popd** - **prompt** - **pushd** - **set** - **setlocal** - **shift** - **start** (also includes changes to external command processes)
- Enable delayed environment variable extension
If you enable the delayed environment variable extension, you can use the exclamation character to replace the value of the environment variable at runtime.
- Enable complete file and folder names
Completion of file and folder names is not enabled by default. You can enable or disable the filename completion feature for a specific procedure of the cmd command with / f: { on | off }. You can enable or disable the filename and folder completion feature for all processes of the cmd command on the computer, or for the user's login session by setting the following REG_DWORD values:
HKEY_LOCAL_MACHINESoftwareMicrosoftCommand ProcessorCompletionCharREG_DWORD HKEY_LOCAL_MACHINESoftwareMicrosoftCommand ProcessorPathCompletionCharREG_DWORD HKEY_CURRENT_USERSoftwareMicrosoftCommand ProcessorCompletionCharREG_DWORD HKEY_CURRENT_USERSoftwareMicrosoftCommand ProcessorPathCompletionCharREG_DWORD
To set the REG_DWORD value , run Regedit.exe and use the hexadecimal value of a control character for a specific function (for example, 0 × 9 is TAB and 0 × 08 is BACKSPACE). User-specified settings take precedence over computer settings and command line options take precedence over registry settings.
Careful:
Modifying the registry incorrectly may damage your system. Before making changes to the registry, you should back up any important data on your computer.
If you enable file and folder name completion using / f: on, use CTRL + D to complete the folder name and CTRL + F to complete the file name. To disable a specific completion character in the registry, use the value for whitespace [ 0 × 20 ] because it is not a valid control character.
When you press CTRL + D or CTRL + F, the cmd command will process the file and complete the directory name. These important aggregation functions add a wildcard to the String (if not yet), build a list of appropriate paths, and then display the first valid path. If there is no suitable path, the filename and folder completion function will beep and not change the display.
To move through the list of matching paths, press CTRL + D or CTRL + F multiple times. To move through the list in the opposite direction, press SHIFT and CTRL + D or CTRL + F simultaneously.
To cancel the list of saved links and create new lists, edit the String and press CTRL + D or CTRL + F. If you switch between CTRL + D and CTRL + F, the saved list of lines Appropriate leads will be canceled and new listings will be created.
The only difference between CTRL + D and CTRL + F is CTRL + D that matches only the folder name and CTRL + F that matches both the file name and the folder. If you use the filename and directory completion feature on any integrated directory command (ie, CD, MD, or RD), then directory completion is assumed.
Completing the file name and folder correctly handles file names containing spaces or special characters if you place quotation marks around the appropriate path.
The following special characters require quotation marks: & <> [] {} ^ =; ! '+, `~ [white space].
If the information you provide contains spaces, use quotation marks around the text (eg "Computer Name").
If you handle complete file and directory names from within the String, any part of the Path to the right of the cursor will be destroyed (at a point in the String where the processing is complete).
See more:
- The chcp command in Windows
- The certutil command in Windows
- The certreq command in Windows
You should read it
- Del command in Windows
- Fc command in Windows
- Command at in Windows
- The echo command in Windows
- Doskey command in Windows
- Defrag command in Windows
- Set command in Windows
- Eventcreate command in Windows
- Mapadmin command in Windows
- Endlocal command in Windows
- Edit command in Windows
- The flattemp command in Windows
Maybe you are interested
How to fix Mac Homebrew error 'zsh: command not found: brew'
What is the Command key on Windows?
How to use read command in Linux
Basic Linux commands everyone needs to know - Operations on Linux are much faster
How to use the ipconfig command to refresh and reset IP address
How to use Command Prompt, how to use cmd on Windows