When 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.
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.
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.
“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.
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.
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.
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”
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”.
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).
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