The Windows Command Prompt: Simpler And More Useful Than You Think

Ryan Dube 01-08-2012

command promptWhen most people think of the old DOS command prompt window – that archaic, lingering vestige of computer days gone by – they think of those simple commands that nearly everyone learned if they had to use a computer during those early days.


Folks learned how to see a directory content with DIR or how to navigate from one directory to the next with CD. Not all commands were very intuitive, and of course before long we had that wonderful graphical user interface of Windows 3.1 (still my all-time favorite) and beyond.

One would thing that with the advent of the graphical user interface, there would be no need for using any sort of command-line activities – yet the CMD tool lingers on from one generation of Windows to the next.

The commands haven’t always stayed the same, in fact some have been trashed while other newer commands came along, even with Windows 7 in fact. So, why would anyone want to bother clicking the start button and typing “CMD” into the Run field? Let me show you why.

The Magic of the Windows Command Prompt

Windows is without a doubt filled with lots of features and tools for you to do all sorts of things like run disk drive diagnostics, search through thousands of files across multiple directories, and copy/paste everything from pictures and documents to files and directories.

Yes, the interaction of Window and Mouse have come a long way, but do you always remember where to find what you need to do? Do you always recall, quickly, where you need to click?


Let’s take a look at several very simple but extremely useful CMD commands that you can use in Windows 7. The following are 13 commands that will save you the time and headache of having to click, click and click. Instead, click Run, “CMD” and then type your command. Done.

Before we get started, find cmd.exe in C:/windows/system32/, create a shortcut and place it on your desktop. Then right click it and select properties.

command prompt

Click on the shortcut tab, click on the “Advanced” button, and select “Run as administrator”. For the commands I’m going to share, double click this shortcut to enter the command prompt, so that you can be sure you have admin rights.


1. ASSOC – Associate File Types

So, you went to open up a text document and Windows kindly asked you what program you want to use. Just this once, you’re testing a new text editor, so you click on that selection and forget to uncheck the box that makes this your default selection.

Now, every time you go to open a text file, it uses that new text editor instead of notepad. Do you remember how to set it back?  Not many people do. Instead, open up a command prompt and type the “ASSOC” command.

command prompt commands

This will show you all file associations related to all of the registered file extensions on your system. This is a pretty extensive list, but it gives you everything in a single shot, which is really convenient.


To see the same thing in the Windows GUI, you have to go to Control Panel, click on “Default Program” and the link to associate file types.

The Windows Command Prompt: Simpler And More Useful Than You Think command2

You can use the ASSOC command to associate any file extension with whatever registered file types you have on your system. However, I don’t commonly use it for this – my thing is to quickly free up a file extension that I accidentally associated with some other program. To do this you just type in the file association assignment and leave the right side of the command blank.

command prompt commands


“ASSOC .txt=” tells Windows that the next time I double click on any .txt file, to ask me what program I want to use to open the file. This gives me the opportunity to reassign the file association if I like.

2. CIPHER – Encryption Command

Yes, you have the ability to encrypt and decrypt files and entire directories from the command prompt, but keep in mind that Cipher (EFS) is not supported (fully) on Windows 7 Starter, Home Basic or Home Premium.

If you have any other version, you can run the CIPHER command to enable a directory as an encrypted directory. Any new files you add to that directory will also be encrypted.

command prompt commands

As you can see, my system doesn’t support encryption, but if it did you would see the result at the bottom stating that the 1 directory was encrypted.

If you’d like to play around with this command on your machine, make sure to check out Microsoft’s explanation of how EFS works.

3 & 4. MORE and CLIP – Making Command Output Useful

The next few commands are very simple, but I feel compelled to review them because they come in handy so often, and not everyone knows about them. While you’re going through your various commands and you get huge lists of output – such as a directory listing – it can be really nice to record that output.

You can record the results of a command right to the clipboard using the CLIP command. Just type “| clip” after the command.

windows 7 command prompt

Now, in the example above, I can go into any other application like Excel, Word or Notepad, and just paste that output.

The Windows Command Prompt: Simpler And More Useful Than You Think command6

It is one of the fastest and easiest ways to obtain the complete listing of files in a directory, driver or hardware details about your computer, or any other information that you can pull from your system using any Windows command.

If you instead follow a command by “| MORE”, it will just keep the output on the screen, but instead of scrolling like mad up the screen faster than you can read it, it’ll stop when the screen is full and wait for you to press a keyboard key before scrolling again.

5. COLOR – Have Some Fun

Okay, so we’re not all work and no play here. If you want to stand out, play around with the color scheme of your Windows 7 command window by typing in the color command followed by a two digit number. The first hex digit is the background, and the second is the foreground.

windows 7 command prompt

Just type “color /?” if you can’t remember the codes. Just black and white can get boring, so mix it up a little! If your friends ask you how you did that, just tell them that you’re a world class hacker.

6. DRIVERQUERY – Get Your Driver Information

Working in IT, there is nothing more frustrating than working on communicating with a device, only to learn that the device driver is wrong, or the version is out of date. That headache can be avoided by running the DRIVEQUERY command to get a full list of installed drivers on your system.

Just output it to the clipboard with the CLIP command, or output it to a file with something like, “DRIVERQUERY >> mydrivers.txt”

windows 7 command prompt

The “>>” operator is actually an “append to file” command and it will create the text file and add the details. If the file exists, it’ll append the info at the end. Use “>” if you want it to wipe any old data and create a new file.

7. FC – File Compare

Another really useful command – especially if you’re a writer or a programmer and often find yourself trying to find out what changes took place to a file – is the FC command.

In my example below, I had two self-written biographies and wasn’t sure which was the most recent, so I type “FC /L ryanbio.txt ryanbio2.txt”.

This does an ASCII comparison and actually outputs the sections of text in each file that are different.

The Windows Command Prompt: Simpler And More Useful Than You Think command9

This isn’t the sort of useful feature many people associate with Windows command prompt command – but there it is. I’m not saying it’s a very new or exciting command, but it is a command that can make using the Windows command prompt a much faster and more effective way to get a job done than trying to figure out how to do it in some application.

8 & 9. DEFRAG and CHKDSK – Useful Maintenance Tools

Some people swear that a regular defrag of your hard drive will keep it healthy and will make everything run more smoothly. Other people say the efficiency difference is negligible.

I say, if it’s important to you, then run the command. In fact, just set up a weekly or monthly scheduled task Schedule Daily Tasks With Tasks Till Dawn [Mac] Let's say you just want to schedule a few little daily or weekly tasks on your Mac and you don't feel like hauling out Automator or figuring out a script in AppleScript. Well, a small... Read More to get the job done and you’ll never even have to think about it again.

As you can see from the example below, I use “DEFRAG C: /U /V”.

The Windows Command Prompt: Simpler And More Useful Than You Think command10

The /U switch prints the progress of the defrag to the screen, and /V makes that output verbose. Obviously if you’re running a scheduled task in the background, you wouldn’t bother with that.

Another important maintenance command I run regularly is CHKDSK to monitor the health of my hard disk. I run “CHKDSK c: /F /R”, which will check the C: drive for any problems. If if finds errors it will fix them thanks to /F, and it’ll try to recover readable information from bad sectors thanks to /R.

10 & 11. HOSTNAME and IPCONFIG – Network Troubleshooting Tools

So you’re on the phone with IT and they need the hostname of your computer, what do you do? Yes, you could open up File Explorer, right click on the My Computer and check the Properties, or you can visit “System” in the Control Panel.  If you want to be super-fast though, just open up your command prompt and type in one word – “HOSTNAME”.


I’m sure lots of IT folks are rolling their eyes out there with the mention of IPCONFIG. Why? Well, because it’s one of the first commands that IT techs cut their teeth on. It’s the fastest way to check the IP address and MAC address of a machine, as well as the current state of the network adapter.

The Windows Command Prompt: Simpler And More Useful Than You Think command11

It is also a real life-saver in some situations. I can’t count how many times I’ve had friends struggling with Internet connection issues, and doing a quick “IPCONFIG /RELEASE” followed by “IPCONFIG /RENEW” wipes the slate clean (obtains a new IP and therefore a “fresh” Internet connection from the ISP) and solves all their problems.

12. Function Keys Are Your Friend

Another well protected secret about your command prompt is that Function Keys also have a purpose in Windows 7. While you’re typing one command after another, you can quickly navigate through commands with the following function keys:

F3 – Shows you the last executed command

F4 – Deletes any text you’ve just entered

F7 – Displays the entire list of recent commands you’ve used

F9 – Lets you select one of the commands from the F7 list to paste to the command line

It would have been really nice to have those function key features in the earliest days of DOS, when we had to type and retype commands if there were typos or mistakes. These days, you can whip out commands much faster than you could ever hope to navigate through various windows with point-and-click.

13. TREE – The Powerful Directory Visualizer

I think the coolest command that I stumbled upon is the “TREE” command. This simple and fast command will output an entire visual map of the directory structure, starting at the path location you define.  This is definitely one that you want to output to a text file.

In the example below, I used the command “TREE /a >> treeresults.txt”.

Since I was already sitting in “C:/Owner/” when I typed the command, it started drilling down through all of the directories in the “Owner” folder, and output the entire structure in an ASCII graphic (thanks the the /a switch).

command prompt

So, there you have it – 13 simple yet powerful commands that can make your computing experience a lot more efficient. And if you want to get a little creative, you could try your hand at writing batch files that incorporate several of them together!

Did I convince you to try out the Windows command prompt for the first time? Were there any commands listed here that were new to you? Share your thoughts and your own CMD tips in the comments section below.

Image Credit: Command Prompt via Shutterstock

Related topics: Command Prompt, MS-DOS.

Affiliate Disclosure: By buying the products we recommend, you help keep the site alive. Read more.

Whatsapp Pinterest

Leave a Reply

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

  1. Jim
    January 18, 2017 at 6:41 am

    Is the help switch "/?" still valid for having it show a list of all the switches and what they do for the particular command? I remember using it for creating a list of the various switches used for pkzip. I'd send the list to my printer and viola! I had a hard copy of a "user guide" of switches for the program.

  2. Saad
    October 30, 2012 at 1:10 pm

    cool article , goold old DOS days, i use MEMMAKER command to increase my free memory.

  3. Sonuva Jack
    August 14, 2012 at 2:46 pm


    • Jerry
      August 27, 2012 at 2:25 pm

      I use the command prompt for all sorts of things. Guess its because I cut my teeth on Unix! Anyway, I've found a limitation that is frustrating:

      What I really want to do, is exactly like what I can do in unix (eg. in the bash shell), but in the Windows command shell.

      e.g. in bash I can do this:

      echo "The quality of mercy "\
      > "is not strain'd. "\
      > "It droppeth as the gentle rain"\
      > "from heaven."
      The quality of mercy is not strain'd. It droppeth as the gentle rain from heaven.

      Can I do the same in the Windows shell? That is, can I start the echo command with one phrase, then continue it to the next line and the next and the next?

      Here's another example. Say I want to copy several files into one file. Copy let's me do this:

      copy foo+bar baz

      Now, consider a case where the filenames are long. For readability, I'd like to do this:

      "this is the first file with a long name" +
      "this is the second file with an even longer name"
      "this is the concatenation of the first and second files"

      Can this be done in the standard Windows shell? If so, what would I type for the ?

    • Jerry
      August 27, 2012 at 2:26 pm

      Oops. didn't know it wouldn't preserve my formatting. Let's see if this works:

      What I really want to do, is exactly like what I can do in bash, but in the Windows command shell. 
      e.g. in bash I can do this:
      echo "The quality of mercy "\
      > "is not strain'd. "\
      > "It droppeth as the gentle rain"\
      > "from heaven."
      The quality of mercy is not strain'd. It droppeth as the gentle rain from heaven.
      Can I do the same in the Windows shell? That is, can I start the echo command with one phrase, then continue it to the next line and the next and the next?
      Here's another example. Say I want to copy several files into one file. Copy let's me do this:
      copy foo+bar baz
      Now, consider a case where the filenames are long. For readability, I'd like to do this:
      "this is the first file with a long name" + 
      "this is the second file with an even longer name" 
      "this is the concatenation of the first and second files"
      Can this be done in the standard Windows shell? If so, what would I type for the ?
  4. JayF
    August 7, 2012 at 12:35 am

    I never throw away my old DOS manuals, either in book form or digital. They DO come in handy when all else fails. I've forgotten how old my copy of "Mostly Windows with just enough DOS" is -- but it sure came in handy when Windows 7 started acting up! I also have manuals for other programs like Visual Basic and Linux.

    • Ryan Dube
      August 7, 2012 at 4:43 pm

      I agree...I am hoping against hope that CMD never goes away or gets completely and totally replaced by PowerShell.

  5. sampath widushan
    August 5, 2012 at 4:05 am

    this is nice..

  6. Sampath Widushan
    August 4, 2012 at 4:58 pm

    Wow...nice post Ryan..this was very useful...and i didn't thought that cmd was this much capable of doing handy work..thank you very much.

  7. Alex Livingstone
    August 3, 2012 at 7:23 pm

    I love the cmd, great article.

  8. Anandu B Ajith
    August 3, 2012 at 11:12 am

    Good things to know!

  9. Timothy Liem
    August 3, 2012 at 9:14 am

    still less powerful than Linux's terminal for sure.

  10. Rigoberto Garcia
    August 2, 2012 at 10:06 pm

    Great article Ryan. We use some. Bat in our daily operations to automate some tasks (the latter was used. RoboCopy bat with a task of Windows). Share this information with my colleagues. Thank you very much ...

  11. Evan Spangler
    August 2, 2012 at 4:50 pm

    CMD is very useful for IT techs, too.

  12. Sushil Kathpalia
    August 2, 2012 at 4:16 pm

    some of them are known but file comparing, TREE,CIPHER and file associates unknown to me..
    So i would try all these commands...

  13. Joe Golla
    August 2, 2012 at 3:13 pm

    Great article, it comes in the wings of needing to PIPE a directory listing to a txt file and import to a spreadsheet for sorting. (dir > print.txt)

    • Ryan Dube
      August 7, 2012 at 4:41 pm

      I'd think there's a way to send it to txt file and then kick off a windows script that parses it into csv format? I've written such scripts before but not specifically for command output files. Would be a fun project though.

  14. Russ
    August 2, 2012 at 2:08 pm

    "start ." is a useful command for easily switching back and forth between the command prompt and windows explorer. It simply opens windows explorer in the current working directory.

    • Ryan Dube
      August 7, 2012 at 4:40 pm

      Sweet - nice tip Russ. I actually didn't know about that one!

  15. vineedcool
    August 2, 2012 at 1:29 pm

    nyc info on cmd ,,,

  16. Rizwan Saudagar
    August 2, 2012 at 12:28 pm

    Useful info.. Thanks for article..

  17. Alan Wade
    August 2, 2012 at 11:30 am

    A few more tricks with the command prompt window that I wrote about in another forum.
    To change the default settings, right click on the icon in the top left hand corner and select 'Defaults'.
    In the window that opens click on the 'Font' tab.
    Now by clicking on the different font sizes you will see in the little preview window the Command prompt window changing. It will alter to the font size you choose. Here you can select one of the three available fonts if you want to change it.
    Click on the 'Layout' tab next now the trick with this screen is to decide how big or small you want the window to be first.
    For this tutorial I have the window size set to 80 characters wide and 20 rows high.
    With the buffer size, if I set it smaller then the window will reduce to the same size.
    If I set it higher then you will have scroll bars on the window.
    If I set it the same size then once the window is full with text, it will disappear from the top of the window as shown in the screenshot, so you must figure out what sizes suites your needs.
    If you uncheck the 'Let system position window' box then you can set the window to open where you want it to.
    Finally the 'Colors' tab.
    Here you set the screen text and the background colours and you can change your popup window's text colour and background here.
    Press F1 or the Right Arrow key to retype the last command, one character at a time.
    Press the Up Arrow key to cycle through the last commands entered.
    Press F3 to retype the entire last command you entered.
    Press F7 to open a popup menu, from which you can select the previously entered command available in the buffer. Use the arrow keys to move up and down in the list and press Enter to select a command. To close the popup menu without selecting a command, press Esc.
    Press F9 to select a command by number. The numbers are the same as seen in the popup menu accessed using F7; however, the numbers are not displayed. To check the numbers for the command, press F7 again and then press Esc to close that popup menu.
    To select a command enter the number for the command and press Enter. To close the popup without entering a number, press Esc.

    • Ryan Dube
      August 7, 2012 at 4:39 pm

      These are excellent tips Alan - thanks so much for posting them. I've saved them in my personal notebook of cmd notes. :-)

  18. imad
    August 2, 2012 at 10:24 am

    Great article. Even with windows7, we can never give up cmd because it is so useful and convenient. Just to highlight some of the other commands like ping, fdisk /mbr, format and dos prompt is very useful for running some old ms-dos programs. Also there is a search for text within files and directories.

    • Ryan Dube
      August 7, 2012 at 4:38 pm

      Definitely - there's something to be said for the convenience of just popping open a command window and getting the job done, versus point and click-click-clicking...

    • Micheal
      March 31, 2015 at 8:18 am

      Just to warn the beginners out here, "fdisk /mbr" and "format" are potentially very dangerous commands and should be researched further before being experimented with.

  19. Luke Brannon
    August 2, 2012 at 7:40 am

    I used to use CMD a lot on my IT course and it was great when sorting out computer networking problems however I don't get round much to using it in everyday life now :(

  20. Austin
    August 2, 2012 at 5:18 am

    Cool, I always find myself using cmd in Windows occasionally, usually just to use handy programs like ffmpeg or youtube-dl that I use in Linux, but need to use for whatever reason in Windows. How does the standard cmd compare to Powershell?

    I still prefer bash though :)

    • Ryan Dube
      August 7, 2012 at 4:38 pm

      Austin - I recently attempted to teach myself PowerShell and realized that the complexity would require too much of my time at the moment. With that said - it looks like an amazing/powerful scripting language, but it's a lot different than the cmd scripts that we're used to, that's for sure.

      From what I hear, Powershell is here to stay, so it's worth learning, for sure.

      • James Graham
        August 23, 2012 at 3:16 am

        I've just taken up PowerShell scripting at work for admin functions, etc. I think I'm lucky that I never got the hang of VB or BASH, etc as this is a bit of a different animal <-- but it is incredible what it can do. it's also nice that they have setup some common aliases so you can use 'get-help' or 'man', 'get-childcontent' or 'dir' or 'ls', etc.

  21. Ravi Meena
    August 2, 2012 at 4:34 am

    how about some command for printing files with printers, creating bat files and automating tasks. i have been doing a little in my office but would like to see other people's works.

    • Ryan Dube
      August 2, 2012 at 5:27 am

      Thanks Ravi - search MUO for "command" or "cmd". We're written a lot of articles on the topic and I know in particular I've written a bunch on bat files and windows scripts that you may find helpful. Like you, I'd love to read about scripts that others have written.

  22. Lee
    August 2, 2012 at 2:02 am

    Another neat thing is that all of these can be put in shortcuts.
    Just make a new shortcut and set the location to:
    cmd.exe /k

    • Ryan Dube
      August 2, 2012 at 5:27 am

      Cool tip - thanks Lee!

  23. Pedro Oliva
    August 2, 2012 at 1:31 am

    great article... so useful thanks :)

  24. neonblade
    August 2, 2012 at 12:25 am

    Enjoyed the article, brings back memories of my DOS days.
    I like using DEFRAG from the command prompt in Windows 7, as I miss the Visual progress indicators from earlier Versions of the OS.

    • Ryan Dube
      August 2, 2012 at 5:26 am

      I agree. I suppose if someone was very ambitious they could write some kind of Windows script that launches the defrag command, outputs to a file and then actively reads that file as it's being created. I don't even know if that's possible but it sounds interesting. :-)

      • Scutterman
        August 3, 2012 at 4:52 pm

        I think the visual indicators went due to increasing disk sizes. When you had 100MB disks, it didn't take a large output to display the clusters, but when you have 500GB, or even 1-2TB, that's a whole lot of clusters.

      • Scutterman
        August 3, 2012 at 5:00 pm

        I use the "ping" command to test network connectivity. I can usually use it to tell whether a site is being slow, or my connection, and if my connection has completely dropped out, ping will sometimes bring it back up. I've also had ping inform me of DNS issues before.

  25. Paul Harris
    August 1, 2012 at 11:39 pm

    When using the command prompt, typing cd.. takes you back one directory.
    Typing cmd /? list lots of information.
    Typing /? after a command ....say defrag or chkdsk will list all the options.

    Be careful, very careful, when typing commands; you could mess up your system and have difficulty restoring it.

    • Ryan Dube
      August 2, 2012 at 5:24 am

      Very good tip and true - that is one of the things about using commands, it is sometimes a little too easy to fat-finger something and cause some major problems. Thanks for the warning.

      • James Graham
        August 23, 2012 at 3:12 am

        I have found over the years in working in IT departments that the GUI has cause many more 'oops' than the command line. One of the reasons I've found it to be my friend. Thanks for this article, found a few gems in here!

  26. Mike Vaz
    August 1, 2012 at 11:01 pm

    Good things to know!

  27. Igor Rizvi?
    August 1, 2012 at 10:40 pm

    I lvoe workign with cmd, great article!