If you are from Dos generation, you will agree that the Dos tricks were best shortcuts to get the work done. Thankfully Windows has continued using Dos in its Windows iteration and you can use Command Prompt to execute tricks even in Windows 10.

For those who have not used Dos commands, the Windows Command Prompt tool, and many of its commands might seem boring or even relatively useless at first glance, but as anyone who has ever used the Command Prompt very often can tell you, there’s much to love!

Here are some Command Prompt tricks and hacks that can make your life easier with PC/laptop :

Use Ctrl-C to Abort a Running Command

Just like any command can be stopped in its tracks with the abort command: Ctrl-C.

Did you know you can stop a command running in the Command Prompt before it completes its task? Well, you can do this by pressing Ctrl + C during the execution of the command.

Become a Command Prompt Power User with Function Keys

The fact that the function keys actually do something in the Command Prompt is maybe one of the best-kept secrets in Windows. Did you know that these function keys play a very useful role in the Command Prompt execution? Perhaps not. Below are the function keys that work as Command Prompt shortcuts :

F1 – It pastes the command that was last executed by the Command Prompt, one character at a time.

For example, if the last command was dir, you’ll have to press F1 three times because dir has three characters.

F2 – It pastes the command that was last executed by the Command Prompt, however, it asks you to enter a character upto which you want to paste the command.

For example, if the last command was ipconfig /displaydns and you press d after pressing F2, the Command prompt will paste ipconfig / i.e. it will paste all characters before d.

F3 – It pastes the last executed command (the whole command).

For example, if the last command was ipconfig /displaydns and you press F3, the Command Prompt will paste ipconfig /displaydns at the location of the cursor.

F4 – It displays a dialog which asks the user to enter the character to delete up to.

Note :- When I pressed F4 in my Command Prompt Window, it showed the dialog box mentioned above, but it did not perform any task, no matter which character I entered.

F5 – It pastes the last executed command. When pressed repeatedly, it shows all the commands executed, in the reverse order of execution. Once the oldest command i.e. the command which was the first to be executed in that cmd session has been displayed, pressing the F5 key does nothing.

F6 – Pastes ^Z to the command prompt.

F7 – It displays a navigable list of previously used commands in the form of a dialog.

F8 – It pastes recently executed commands. Please note that it is different from F5 because it keeps cycling the previously used commands.

F9 – As mentioned above, the command prompt stores a list of all the executed commands. This list is numbered from0 to 9. When you press F9, you’re asked to enter the number of the command, which you want to use.

For example, to use the first command, type 0. For using the third command, type 2, and so on.

Hack the Prompt Text itself

Did you know that the prompt itself in the Command Prompt is completely customizable thanks to the prompt command? It is, and when I say customizable, I mean really customizable. Instead of C:\>, you can set the prompt to any text you want, have it include the time, the current drive, the Windows version number, you name it.

One useful example is prompt $m$p$g which will show the full path of a mapped drive in the prompt, alongside the drive letter.

You can always execute prompt alone, without options, to return it to its sometimes boring default.

Save a Command’s Output to a File

Sometimes you may need to save the output of a command to a file for future reference, or maybe for posting it in some forum for getting help from others regarding the error(s) displayed in the output of that command. You can do this easily by typing <command> “>” (without quotes) followed by a filename after the command you’re going to execute.

For example, you might execute systeminfo > c:\mycomputerinfo.txt to save the information provided by the systeminfo command to that file. You could then attach the file to your forum post. Similarly, if you want your IP configuration in a single text file type For example, ipconfig /all > ipconfig.txt

Copy the output of a command to clipboard

To copy the output of a command to clipboard instead of saving it to a file, you can type <command> | clip

For example, systeminfo /all | clip

Run multiple commands simultaneously

Did you know you could execute multiple commands simultaneously?  Yes, You can run multiple commands at the same time using “&&” (without quotes) between two commands and pressing Enter. The command on the left will be executed first, followed by the next command, and so on.

For example, dir && systeminfo /all

Copy Text From the Command Prompt

As you may or may not know, copying from the Command Prompt is not as easy as copying from other programs, which is part of the reason why saving a command’s output to a file, which you learned about a few tricks back, is so handy.

But what if you just want to copy a short section of text to the clipboard? It’s not too hard but it’s not very intuitive either:

  • Right-click anywhere in the Command Prompt window and choose Mark.
  • Now, highlight with your left mouse button whatever you’d like to copy.
  • Once your selection is made, press Enter.

Now you can paste that information into whatever program you’d like, just like you paste other text.

Use Robocopy as a Backup Solution

Thanks to the robocopy command, you don’t need to use Window’s backup software or install a third-party program to manage your backups.

Just execute robocopy c:\users\vijay\documents f:\backup\documents /copyall /e /r:0 /dcopy:t /mir. Replace the source and destination folders with whatever you’d like to backup and where. The robocopy command with these options functions identically to an incremental backup software tool, keeping both locations in sync.

Earlier Windows versions like Windows XP didn’t have the robocopy command, hence you had to make do with xcopy command which is similar to robocopy. The command for xcopy is c:\users\vijay\documents f:\backup\documents /c /d /e /h /i /k /q /r /s /x /y.

No matter which command you choose to use, just create a script file containing the command and schedule it to run in Task Scheduler and you’ll have your own custom made backup solution.

Run cmd as administrator without using the mouse

There are several commands that require the Administrator’s privilege. For running these commands, you need to run cmd as administrator. However, right-clicking the cmd.exe file and selecting Run as Administrator from the list is highly inconvenient. We can help you make CMD run with Administrator’s privileges every time without using the mouse. There are two ways to do this:

  •  Type cmd in the Start Menu’s search box and press Ctrl + Shift + Enter
  •  Create a shortcut of cmd. Right click the shortcut file and click on Properties. Under the Shortcut tab, click on the button named Advanced. A new dialog box appears. Check the checkbox labeled Run as Administrator and Click OK. Click OK again to close the Properties Window of the shortcut. Now, whenever you want to open a command prompt window with administrator’s privileges, you’ll have to only double-click this shortcut.

Automatically Complete Commands with Tab Completion

Tab completion is another Command Prompt trick that can save your lots of time, especially if your command has a file or folder name in it that you’re not completely sure of.

To use tab completion in the Command Prompt, just enter the command and then the portion of the path that you do know, if at all. Then press the tab key over and over to cycle through all of the available possibilities.

For example, let’s say you want to change directories to some folder in the Windows directory but you’re not sure what it’s named.

Type cd c:\windows\ and then press tab until you see the folder you’re looking for.

The results cycle or you can use SHIFT+TAB to step through the results in reverse.