Most Useful Command Prompt Tricks

By | September 6, 2017

Command Prompt, also known as cmd.exe or cmd (after its executable file name), is the command-line interpreter on windows family of operation systems. You can do lots of amazing stuff with this little tool with very minimal effort. You can use it for coping files from one place to other or you can use to change extension of all the files in a directory. Here is a small list of tips for command prompt users.

1. Open the Command Prompt From Any Location

If you’ve ever worked in the Command Prompt for very long, you know that it can be really frustrating executing the cd/chdir command over and over (and over) again to get to the right directory you want to work from.

Fortunately, there’s a super easy Command Prompt trick that will let you open a Command Prompt window from whatever folder you’re viewing in Windows.

All you have to do is navigate, in Windows, to the folder you’d like to start working from in Command Prompt. When you’re there, hold down the Shift key while you right-click anywhere in the folder.

Once the menu pops up, you’ll notice an entry that’s not usually there: Open command window here.

Click that and you’ll start a new instance of the Command Prompt, ready and waiting at the right location!

If you’re a Command Prompt power user, you’ll immediately recognize the value in this little trick.

2. Drag and Drop For Easy Path Name Entry

Most Command Prompt commands require you, or have options, to specify full paths to files or folders, but typing out a long path can be frustrating, especially when you miss a character and have to start over.

For example, in Windows 10, the path to the Accessories group in my Start Menu is C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories. Who wants to type that all in manually?

Fortunately there’s a Command Prompt trick that makes this much easier: drag and drop.

Just navigate to the folder you want the path for in Windows Explorer. Once there, drag the folder or file to the Command Prompt window and let go. Like magic, the full path is inserted, saving you a considerable amount of typing depending on the length and complexity of the path name.

Unfortunately, the drag and drop feature does not work in an elevated Command Prompt. At least you learned a few tricks back how to open one of those a bit quicker!

3. Use Ctrl-C to Abort a Command

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

If you haven’t actually executed a command, you can just backspace and erase what you’ve typed, but if you’ve already executed it then you can do a Ctrl-C to stop it.

Ctrl-C can’t undo things that aren’t undo able, like a partially complete format command.

However, for things like the dir command that seem to go on forever or questions you’re asked at the prompt that you don’t know the answer to, the abort command is an excellent Command Prompt trick to know.

4. View a Command’s Results One Page (or Line) at a Time

Ever run a command, like the dir command, that produces so much information on the screen that it’s almost useless?

One way around this is to execute the command in a special way so whatever information is generated is shown to you one page, or one line, at a time.

To do this, just type the command, the dir command for example, and then follow it with the pipe character and then the more command.

For example, executing dir /s | more will generate the thousands of lines of results that you expect from the dir command, but the more command will pause each page of results with — More — at the bottom of the page, indicating that the command is not done running.

Just press the space bar to advance by page or press the Enter key to advance one line at a time.

5. Run Command Prompt as an Administrator Automatically

Many commands require that you execute them from an elevated Command Prompt in Windows – in other words, execute them from a Command Prompt that’s run as an administrator.

You can always right-click on any Command Prompt shortcut and choose Run as administrator but creating a shortcut to do the same thing can be a huge time saver if you’re a frequent Command Prompt power user.

To complete this Command Prompt trick, just create a Command Prompt shortcut on the desktop, enter the shortcut’s properties and then select the Run as administrator box located in the Advanced button on the Shortcut tab.

6. Get Help for Any Command

Believe it or not, the help command does not provide help for every Command Prompt command.

However, any command can be suffixed with the /? option, usually called the help switch, to display detailed information about the command’s syntax and often times even some examples.


7.  Save a Command’s Output to a File

An incredibly useful Command Prompt trick is the use of redirection operators, specifically the > and >> operators.

These little characters let you redirect the output of a command to a file, giving you a saved version of whatever data the command produced in the Command Prompt window.

For example, let’s say you’re about to post a computer problem to an online forumand you want to provide really accurate information about your computer. An easy way to do that would be to use the systeminfo command with a redirection operator.

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.


8. Shut Down or Restart Another Computer

System administrators in a business environment do this all the time for lots of reasons, but you can also shut down or restart another computer on your network, all from your computer’s Command Prompt.

The easiest way to shut down a computer remotely is to execute shutdown /i from the Command Prompt to open the Remote Shutdown Dialog, shown here.

Just enter the name of the remote computer (which you can get by running the hostname command on the other PC), choose what you want to do (restart or shutdown), select some other options and then click OK.

You can also shut down or restart another computer strictly from the Command Prompt with the shutdown command, without using the Remote Shutdown Dialog.

9. Use Robocopy or XCopy 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\skn\documents f:\mybackup\documents /copyall /e /r:0 /dcopy:t /mir, obviously replacing the source and destination folders with whatever you’d like to backup and where it should go. The robocopy command with these options functions identically to an incremental backup software tool, keeping both locations in sync.

You don’t have the robocopy command if you’re using Windows XP or earlier. However, you do have the xcopy command, which can be used to do something very similar: xcopy c:\users\skn\documents f:\mybackup\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.

10. Automatically Complete Commands With Tab Completion

tab completion is another Command Prompt trick that can save you 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 in order or you can use SHIFT+TAB to step through the results in reverse.

11. Find a Website’s IP Address

Like to know the IP address of a website? You can use the nslookup command or the ping command, but the former is probably faster.

First, let’s use the nslookup command to find the IP address of

Just execute nslookup and view the result. Make sure you don’t confuse any private IP addresses that also show up in the nslookup results alongside the public IP address of, which is what IP address we’re after.

Now let’s try using the ping command to find it:

Execute ping and then look at the IP address between the brackets in the first line shown. Don’t worry if the ping command “times out” during execution; all we needed here was the IP address.

You can use the same procedure with any website or any hostname on your local network.

12. Copy and Paste Easier With QuickEdit Mode

A number of these Command Prompt tricks have dealt with making copying and pasting easier. So, how about an even easier way to copy from the Command Prompt (and a secret way to easily paste)?

Just right-click on the Command Prompt title bar and select Properties. On the Options tab, in the Edit Options section, check the QuickEdit Mode box and then click OK.

Enabling QuickEdit Mode is like having Mark enabled all the time, so selecting text to copy is really easy.

As a bonus, this also enables an easy way to paste into the Command Prompt: just right click once and whatever you have in the clipboard is pasted in the Command Prompt window. Normally, pasting involves right-clicking and selecting Paste, so this is still a bit different than you’re used to.

13. View Your Computer’s Important Network Information

Maybe just for your own information, but certainly when you’re troubleshooting a network or internet problem, you’ll probably at some point need to know details about your computer’s network connection.

Everything you’d want to know about your network connection is available somewhere in the Control Panel in Windows, but it’s much easier to find, and much better organized, in the results from the ipconfig command.

Open Command Prompt and execute ipconfig /all.

What displays on screen next is everything important about your network connection: your IP address, hostname, DHCP server, DNS information, and much, much more.

Combine this hack with the one about redirection operators that you learned about several slides back and you’ve got a very easy way to get information about your connection to someone helping you with a problem.

Leave a Reply

Your email address will not be published. Required fields are marked *