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

Ads by Google

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.

Ads by Google

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.

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.

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.

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 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 /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”.

Done.

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.

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

Join live MakeUseOf Groups on Grouvi App Join live Groups on Grouvi
Windows Troubleshooting
Windows Troubleshooting
10 Members
Windows_10
Windows_10
9 Members
Windows Hacks & Customization
Windows Hacks & Customization
21 Members
Best Windows Software
Best Windows Software
13 Members
Ads by Google
Comments (43)
  • Saad

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

  • Sonuva Jack

    cool

    • Jerry

      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.
      jerryb1@ubuntu:~$

      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:

      copy
      “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

      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.
      jerryb1@ubuntu:~$
      
      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:
      
      copy 
      "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 ?
      </pre

  • JayF

    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

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

  • sampath widushan

    this is nice..

  • Sampath Widushan

    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.

Load 10 more
Affiliate Disclamer

This review may contain affiliate links, which pays us a small compensation if you do decide to make a purchase based on our recommendation. Our judgement is in no way biased, and our recommendations are always based on the merits of the items.

For more details, please read our disclosure.
Affiliate Disclamer

This review may contain affiliate links, which pays us a small compensation if you do decide to make a purchase based on our recommendation. Our judgement is in no way biased, and our recommendations are always based on the merits of the items.

For more details, please read our disclosure.