Tips for using cmd.exe Command Prompt

Source: Internet
Author: User
(This article is transferred from

1. Use the Automatic Memory Function

The command window has the command memory function. All the command lines you enter in the window will be automatically remembered. You can click the up and down arrow keys on the keyboard to retrieve the commands you just entered one by one, it is similar to the doskey command in DOS, except that it is embedded in the Command window. This memory function saves you the trouble of repeatedly inputting the same command and is especially useful for debugging in the network environment, saving you a lot of repetitive work and valuable time.
However, sometimes the efficiency of using zookeeper is still relatively low. Now we can use the CMD Shortcut Keys F7 and F9.
Press F7 to view all the commands you entered

Press F9 and enter the command number to quickly execute the corresponding command.

2. Interesting prompt

Would you imagine changing your command prompt to the current time? Can the current Windows XP version be displayed? You can achieve it as long as you want. Next we will teach you how to implement it.

Here we use a prompt doscommand, which has many practical parameters. For detailed parameter functions, please run prompt /? . After learning about the functions of these parameters, you can create a file in the installation path and name it run. BAT, the content in this folder is prompt $ V $ d $ G. Next, open the Registry Editor, browse HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ command processor \, double-click the Autorun key value on the right, and change it to % SystemRoot % \ Run. bat, save the settings and exit. Open the command prompt again. How can this problem be solved. As a matter of fact, you can define a rich variety of prompt text based on prompt parameters.

After we enter prompt $ V $ d $ G $ g, the command prompt will look like the following:

Syntax: prompt [text]
Text: specify a new command prompt.

A prompt can contain common characters and the following code:

$ A & (short and)
$ B | (MPS Queue)
$ C (left arc)
$ D current date
$ E escape code (ASCII code 27)
$ F) (Right arc)
$ G> (greater than the symbol)
$ H backspace (erased the previous character)
$ L <(less than the symbol)
$ N current drive
$ P current drive and Path
$ Q = (equal sign)
$ S (Space)
$ T current time
$ V Windows XP version
$ _ Line feed
$ (Currency)

If the command extension is enabled, the prompt command supports the following formatting characters:

$ + Based on the pushd directory stack depth, there are zero or more plus sign (+) characters. Each pushed layer has one character.
$ M if the current drive is not a network drive, the remote name associated with the current drive letter or empty string is displayed.
3. Copy the window content

Copying strings is quite useful for the command window. However, the command prompt COPY method for Windows 2000 and Windows XP is significantly different from the previous version, even if the two are not the same, the former adopts the mark COPY method, the latter directly uses the copy method by right-clicking. The detailed description is as follows:

In Windows XP, you can right-click all content to select all content, you can right-click and select the "tag" item, move the mouse to the command character to be copied, and drag the mouse to select the string, these strings will immediately appear on the screen in the form of anti-white, right-click or press the Enter key, move to the target location, right-click and select "Paste ", in this way, a command string is automatically copied to the specified position.

In Windows 2000, the right-click menu is not supported in the Command window (however, you can drag the mouse to select a menu ), therefore, it provides a more concise way to copy the daily command characters. First, you must press and hold the left mouse button to drag and select the command string to be copied, they will appear on the screen in the form of anti-white, right-click the mouse (that is, execute the copy operation), move the mouse to the target position, and then click the left mouse button again, the command characters are automatically pasted to the new location!

4. Change window features

If you have been working in a command prompt for a long time, you can also adjust its appearance to adapt to your usage habits, such as personalized settings of its window title and color, frequently Used commands are as follows:

A) change the title: CMD/K title New title
B) Change the command line: CMD/K prompt [text] (text is a new command prompt)
C) Change the foreground color and background color: CMD/T: GF (G indicates the hexadecimal number of the background color. Common colors include 0 black, 1 blue, and 2 green, 3 light green, 4 red, 5 purple, 6 Yellow, 7 White, 8 gray, 9 light blue, a light green, B light blue, C light red, d light purple, e light yellow, F light white.

5. Shortcut Keys in the Command window

There are many easy-to-use shortcut keys in the Command window, which can greatly speed up your input and debugging, and some functions are also provided in graphics.
Commands, commands: select commands
ESC: clears the current command line;
F7: displays the command history. All commands that have been input are displayed in the graphic list window. You can use the up and down arrow keys to execute the command again.
F8: Search for the command history, and display all input commands cyclically until you press the Enter key;
F9: select a command by number. In the graphic dialog box, enter the corresponding number (starting from 0) of the command and display the command on the screen;
CTRL + H: delete a character on the left of the cursor;
CTRL + C Ctrl + break, force Stop command execution;
CTRL + M: Press enter to confirm the key;
Alt + F7: Clear all command history records that have been entered;
Alt + printscreen: captures the content in the current command window on the screen.

6. Good "color" command line

By default, the command line is always black and white. In the run dialog box, Enter cmd, open the command prompt, right-click the title of the window to open, and select "attribute" in the pop-up menu ", switch the window to the "color" tab, select the screen text and screen background options, and set the corresponding color, note: After we change the settings, the settings will be displayed in real time below. Based on this, we can make timely adjustments based on our preferences. After saving the settings, we will ask about the application attributes, select "Save attributes for future use in windows with the same title". This will not take effect only for the current window.

7. Quickly select files and folders (automatically completed)

At the command prompt, we can press the tab key to select the files and folders under the current directory. The selection is in a certain order, press SHIFT + TAB to select the reverse direction, which is very convenient. Note: The selected files include hidden files.

8. Change the default location of the command prompt

In Windows XP, open the Command Prompt window. By default, the system locates under "X: \ Documents ents and Settings \ Current User Name>", where X is the drive letter of the operating system. But sometimes we need to work in a specific directory when using a command prompt, so it is necessary to use the "Computer Management" function to change the default location of the command prompt: click Start> Control Panel> performance and maintenance> Management Tools> Computer Management, and expand system tools> local users and groups> Users in turn ", double-click the user name currently logged on in the right window, and click the configuration file tab in the "properties" dialog box that appears, enter the current drive letter or current directory you want to change after "local path" under "Main folder", such as "E: \", and click "Application> OK ", restart the computer to complete the change.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.