- prompt
- Syntax
- Parameters
- Remarks
- Examples
- 27 Useful Windows Command Prompt Tricks You Might Not Know
- How To Use Command Prompt In Windows 10?
- 27 Useful Windows Command Prompt Tricks
- 1. Command History
- 2. Run multiple commands
- 3. Use Function keys and become a pro user
- 4. See PC driver list
- 5. Send output to clipboard
- 6. Abort a command
- 7. Make your Command Prompt colorful
- 8. Create Wi-Fi hotspot right from the command prompt
- If you’re using Windows 10?
- 9. Scan system files for problems
- 10. Start using batch files
- 11. Fix issues with DNS resolver cache
- CMD Alternative: Powershell and Windows Terminal
- Windows new command prompt
- Introduction to the Windows Command Prompt
- Table of Contents
prompt
Changes the Cmd.exe command prompt, including displaying any text you want, such as the name of the current directory, the time and date, or the Microsoft Windows version number. If used without parameters, this command resets the command prompt to the default setting, which is the current drive letter and directory followed by the greater than symbol (>).
Syntax
Parameters
Remarks
The character combinations you can include instead of, or in addition to, one or more character strings in the text parameter:
Character | Description |
---|---|
$q | = (Equal sign) |
$$ | $ (Dollar sign) |
$t | Current time |
$d | Current date |
$p | Current drive and path |
$v | Windows version number |
$n | Current drive |
$g | > (Greater than sign) |
$l | | (Pipe symbol) |
$_ | ENTER-LINEFEED |
$e | ANSI escape code (code 27) |
$h | Backspace (to delete a character that has been written to the command line) |
$a | & (Ampersand) |
$c | ( (Left parenthesis) |
$f | ) (Right parenthesis) |
$s | Space |
When command extensions are enabled the prompt command supports the following formatting characters:
Character | Description |
---|---|
$+ | Zero or more plus sign (+) characters, depending on the depth of the pushd directory stack (one character for each level pushed). |
$m | The remote name associated with the current drive letter or the empty string if current drive is not a network drive. |
If you include the $p character in the text parameter, your disk is read after you enter each command (to determine the current drive and path). This can take extra time, especially for floppy disk drives.
Examples
To set a two-line command prompt with the current time and date on the first line and the greater than sign on the next line, type:
The prompt is changed as follows, where the date and time are current:
To set the command prompt to display as an arrow ( —> ), type:
To manually change the command prompt to the default setting (the current drive and path followed by the greater than sign), type:
27 Useful Windows Command Prompt Tricks You Might Not Know
We talk about Command Prompt in our Windows 10 tutorial posts quite often. Some people unknowingly refer to commands as Command Prompt codes. Speaking of which, there exist tons of Windows Command Prompt tricks that you can learn, use, and impress your friends.
For example, some people may not know how to abort a command or how to watch Star Wars in Command Prompt. Here, we are going to tell you about such interesting Command Prompt tricks.
Windows Command Prompt might look like a black and white world to some users. But the experienced users know the power of Command Prompt and use different cool command hacks and tricks.
So, to make your Windows Command Prompt experience better, in this article, we are going to tell you about some useful Command Prompt tricks that’ll save some extra clicks.
Don’t forget to check out our extensive list of A to Z Windows CMD commands in your free time.
How To Use Command Prompt In Windows 10?
Maybe I don’t need to tell you this. But those who don’t know, you can fire up the command prompt by typing CMD in Windows Search. Right-click on CMD to run it as an administrator.
Alternatively, you can also open Run (Windows + R) > type cmd and press enter. It doesn’t matter whether you’re using Windows 10 or older version, the method is the same.
27 Useful Windows Command Prompt Tricks
1. Command History
Using this command, you can track down your command history. This will turn out to be useful when you are trying to look for some command that you’ve used in the past, but can’t remember.
2. Run multiple commands
If you feel the need to run two commands one after the other, you can do so easily. Add this to your collection of CMD hacks. You just need to put “&&” between each command and save some time. For example, here’s how to run ipconfig and paint.
3. Use Function keys and become a pro user
One out of the very useful CMD tricks is to use function keys. There is a lot these keys can do to improve your CMD experience.
4. See PC driver list
Using a simple command, you can see all the drivers installed on your computer. All you need to do is run the driverquery command, and you’ll be seeing a list of all the drivers along with their name, type, and other information.
5. Send output to clipboard
Very often, you might have felt the need to save the output of a command? Usually, people use copy and paste. However, using a simple command that uses pipe operator, you can send the command’s output to the Windows clipboard. Here’s how to send the ipconfig information:
6. Abort a command
This handy Windows CMD trick comes to rescue when you have pressed the enter key, and you need to stop the command in its tracks? To do it, you need to do a Ctrl+C. However, it isn’t a magic trick that can undo an undoable thing.
7. Make your Command Prompt colorful
You can change the color of the Windows Command Prompt to make it look visually appealing. To do so, right-click in the top corners of the Command Prompt window and select Properties. There, find the Colors tab and look for the options to change the background and text color.
8. Create Wi-Fi hotspot right from the command prompt
Before opening the Command Prompt to execute the commands needed for this, you need to open Control Panel and find Change adapter settings in the Network and Sharing option. There, click on the connection you are using and click on Properties. Now find the sharing tab and check the option “Allow other network users to connect through this computer’s internet connection.”
Now open the Command Prompt with administrative privileges and enter the following command:
After it’s enabled, enter the following command to start the Wi-Fi hotspot
To stop it, simply enter this command:
If you’re using Windows 10?
Windows 10 comes with a built-in tool that lets users create a WiFi hotspot. You can read our detailed post know how to enable mobile hotspot in Windows 10.
9. Scan system files for problems
The sfc /scannow command runs a system file checker tool that scans Windows system files and looks for problems. If some files are missing or corrupted, this command fixes them.
10. Start using batch files
You might already know that batch files can make your life a lot easier when dealing with multiple commands more often. For instance, if you have the habit of using the same CMD commands, you can create a batch file and do away with the task of typing them again and again. All you’ll have to do is run the batch file.
11. Fix issues with DNS resolver cache
You might be knowing that DNS (Domain Name System) is an important thing you can’t ignore when connecting to the internet. To access websites faster, your computer usually maintains a local DNS resolver cache. But sometimes, the cache might get corrupt, and you may not be able to access your favorite sites.
In that case, you can try this Windows command prompt trick to save the day. You can use the Ipconfig utility to remove the DNS cache.
We have already covered many useful Command Prompt tricks and cool hacks in our previous articles. You can read about them and learn how to execute by clicking on the links below:
CMD Alternative: Powershell and Windows Terminal
Over the years, Microsoft has started switching from the good old Command Prompt to its modern successor Powershell. If you might have realized, the places where you could see CMD earlier now show Powershell as the option because it’s the default shell in Windows 10. For example, in the Start button context menu.
You can use it because the commands meant for CMD also work on Powershell.
Furthermore, Microsoft has developed an entirely new command-line experience in the form of a new app called Windows Terminal. It combines the likes of Command Prompt, Powershell, and the Windows Subsystem for Linux. You can read our detailed article on how to set up WSL on your Windows 10 PC.
Unlike CMD and Powershell, Windows Terminal isn’t pre-loaded on Windows 10, and you can get it from Microsoft Store. One thing to note is that Windows Terminal is not available for older Windows versions.
Did you find this article helpful? Tell us in the comments below. Also, if you have some interesting Windows Command Prompt tricks, don’t forget to share them.
Windows new command prompt
- Home
- Tutorials & Tech Support Guides
- Windows 7 Tutorials
- Introduction to the Windows Command Prompt
Introduction to the Windows Command Prompt
Lawrence Abrams
- July 10, 2004
- Read 1,616,566 times
Table of Contents
Introduction
Before Windows was created, the most common operating system that ran on IBM PC compatibles was DOS. DOS stands for Disk Operating System and was what you would use if you had started your computer much like you do today with Windows. The difference was that DOS was not a graphical operating system but rather purely textual. That meant in order to run programs or manipulate the operating system you had to manually type in commands. When Windows was first created it was actually a graphical user interface that was created in order to make using the DOS operating system easier for a novice user. As time went on and newer versions of Windows were developed DOS was finally phased out with Windows ME. Though the newer operating systems do not run on DOS, they do have something called the command prompt, which has a similar appearance to DOS. In this tutorial we will cover the basic commands and usage of the command prompt so that you feel comfortable in using this resource.
Using the Command Prompt or Dos Window
When people refer to the command prompt they may we refer to it in different ways. They may refer to it as a shell, console window, a command prompt, a cmd prompt, or even dos. In order to enter the command prompt you need to run a program that is dependent on your operating system. Below we list the programs that you need to run to enter a command prompt based on the version of Windows you are running.
To run these programs and start a command prompt you would do the following steps:
Step 1: Click on the Start Menu
Step 2: Click on the Run option
Step 3: Type the appropriate command in the Open: field. For example if we are using Windows XP we would type cmd.exe.
Step 4: Click on the OK button
After following these steps you will be presented with a window that look similar to Figure 1 below.
Figure 1. Windows Command Prompt
The command prompt is simply a window that by default displays the current directory, or in windows term a folder, that you are in and has a blinking cursor ready for you to type your commands. For example in Figure 1 above you can see that it says C:\WINDOWS>. The C:\WINDOWS> is the prompt and it tells me that I am currently in the c:\windows directory. If I was in the directory c:\program files\directory the prompt would instead look like this: C:\PROGRAM FILES\DIRECTORY>.
To use the command prompt you would type in the commands and instructions you want and then press enter. In the next section we will discuss some useful commands and how to see all available built in commands for the command prompt.
Useful commands
The command.com or cmd.exe programs have built in commands that are very useful. Below I have outlined some of the more important commands and further instruction on how to find information on all the available commands.
The Help command — This command will list all the commands built into the command prompt. If you would like further information about a particular command you can type help commandname. For example help cd will give you more detailed information on a command. For all commands you can also type the command name followed by a /? to see help on the command. For example, cd /?
The Exit command — This command will close the command prompt. Simply type exit and press enter and the command prompt will close.
The CD command — This command allows you to change your current directory or see what directory you are currently in. To use the CD command you would type cd directoryname and press enter. This would then change the directory you are currently in to the one specified. When using the cd command you must remember how paths work in Windows. A path to a file is always the root directory, which is symbolized by the \ symbol, followed by the directories underneath it. For example the file notepad.exe which is located in c:\windows\system32 would have a path as follows \windows\system32\notepad.exe. If you want to change to a directory that is currently in your current directory you do not need the full path, but can just type cd directoryname and press enter. For example if you are in a directory called c:\test, and there were three directories in that the test directory called A, B, and C, you could just type cd a and press enter. You would then be in the c:\test\a. If on the other hand you wanted to change your directory to the c:\windows\system32 directory, you would have to type cd \windows\system and press enter.
The DIR command — This command will list the files and directories contained in your current directory, if used without an argument, or the directory you specify as an argument. To use the command you would just type dir and press enter and you will see a listing of the current files in the directory you are in, including information about their file sizes, date and time they were last written to. The command will also show how much space the files in the directory are using and the total amount of free disk space available on the current hard drive. If I typed dir \test I would see the contents of the c:\test directory as shown in Figure 2 below.
Figure 2. DIR of c:\test
If you examine the screen above you will see a listing of the directory. The first 2 columns are the date and time of the last write to that file. Followed by whether or not the particular entry is a directory or a file, then the size of the file, and finally the name of the file. You may have noticed that there are two directories named . and . which have special meaning in operating systems. The . stands for the current directory and the .. stands for the previous directory in the path. In the example above, .. stands for c:\windows.
Also note for many commands you can use the * symbol which stands for wildcard. With this in mind, typing dir *.txt will only list those files that end with .txt.
The Copy command — This command allows you to copy files from one location to another. To use this command you would type
copy filetocopy copiedfile. For example if you have the file c:\test\test.txt and would like to copy it to c:\windows\test.txt you would type
copy c:\test\test.txt c:\windows\test.txt and press enter. If the copy is successful it will tell you so and give you back the prompt. If you are copying within the same directory you do not have to use the path. Here are some examples and what they would do:
copy test.txt test.bak | Copies the test.txt file to a new file called test.bak in the same directory |
copy test.txt \windows | Copies the test.txt file to the \windows directory. |
copy * \windows | Copies all the files in the current directory to the \windows directory. |
The Move command — This command allows you to move a file from one location to another. Examples are below:
move test.txt test.bak | Moves the test.txt file to a new file renaming it to test.bak in the same directory. |
move test.txt \windows | Moves the test.txt file to the \windows directory. |
move * \windows | Moves all the files in the current directory to the \windows directory. |
At this point you should use the help command to learn about the other available commands.