Pinterest Stumbleupon Whatsapp
Ads by Google

Don’t feel intimidated! The Windows command prompt The Windows Command Prompt: Simpler And More Useful Than You Think The Windows Command Prompt: Simpler And More Useful Than You Think 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... Read More  is simpler and more useful than you expect. Graphical interfaces may be convenient, but sometimes it’s quicker to run a specific command to perform a specific task.

If you’ve never touched the Windows command prompt, or if you’ve given up on it due to issues in the past, we ask that you reconsider. If you still don’t like it, that’s fine and we won’t blame you. However, we think you might be surprised by what you can accomplish with just a few keystrokes.

Run Any Program Easily

Quick program access is important for productivity. Some of us have taskbars and start menus overflowing with shortcut icons. It’s not an ideal situation, often pushing users to seek out taskbar alternatives like these multifunctional docks 3 Multifunctional Docks To Replace Your Windows Taskbar 3 Multifunctional Docks To Replace Your Windows Taskbar Docks take what the taskbar does and make it better: beautiful, effective, and fun to use. Once introduced for the Mac, docks have long been available on Windows. Let me show you the best ones. Read More .

Fortunately, there may be an answer that you hadn’t considered before. With a little bit of setup, you’ll be able to run any program that you want with a single command.

command-prompt-tasks-path-variable

First, you have to create a new folder (such as C:\Shortcuts). This folder will hold the shortcuts that allow fast-access to any program on your system. Once created, we’ll need to add that folder to the system’s PATH environmental variable What Are Environment Variables & How Can I Use Them? [Windows] What Are Environment Variables & How Can I Use Them? [Windows] Every now and then I'll learn a little tip that makes me think "well, if I known that a year ago then it'd have saved me hours of time". I vividly remember learning how to... Read More :

Ads by Google
  • Right click on My Computer and select Properties.
  • Click on Advanced System Settings.
  • Under the Advanced tab, click on Environment Variables.
  • Under System Variables, edit the PATH variable. Add ;C:\Shortcuts to the end of the variable’s value (don’t forget the semicolon separator).
  • Under System Variables, edit the PATHEXT variable. Add ;.LNK to the end of the variable’s value (don’t forget the semicolon separator).
  • Click OK to close out of all windows.

Now that the environment variable is established, all you have to do is create shortcuts to your programs, place those shortcuts in the C:\Shortcuts directory, and rename them as one-word commands.

command-prompt-tasks-shortcuts

Now, whenever you open up a command prompt, you can run those programs using those shortcut names. The command prompt’s current directory won’t matter. These shortcut commands will work from anywhere.

Rename Local Drives

The label command offers a quick way to change the name of a drive on your system. It’s so simple that there isn’t much to explain about it. Just use it like so:

label [drive:] [name]

For example, if I wanted to name my main drive “MakeUseOf”, I’d run the following command:

label C: MakeUseOf

Defragment Hard Drives

Modern file systems (e.g. NTFS) don’t need to be defragmented as often as file systems of the past (e.g. FAT32), but it’s still an important part of Windows maintenance, if you want to keep your system in tip-top shape. Be cautious with defragmentation of SSDs How to Care for Your Hard Drives and Make Them Last Longer How to Care for Your Hard Drives and Make Them Last Longer Sometimes an early death is the fault of the manufacturer, but more often than not, hard drives fail earlier than they should because we don't take care of them. Read More , though.

Though there are several excellent defragmentation utilities 3 Excellent Defrag Utilities & Why You Still Need to Defragment In 2012 3 Excellent Defrag Utilities & Why You Still Need to Defragment In 2012 Accessing files from the hard drive is a speed limiting step in operating a computer. Hard drives used to be a major bottle neck and fragmentation of data slowed them down even further. With the... Read More , you can still make do without them using the defrag command:

defrag [drive:]

That’s all. However, if you’d like a bit more diagnostic information while the defragmentation occurs, you can use the progress switch to print out progress to the prompt:

defrag [drive:] /U

And if you want as much information as possible, you can toggle the verbose switch:

defrag [drive:] /U /V

Monitor Hard Drive Health

The chkdsk command (read: “check disk”) is a diagnostic tool that scans through your hard drives and tests for potential issues like corrupted data or physical damage. It’s just as easy to use as the defragment command above:

chkdsk [drive:]

Two useful parameters are the fix switch, which attempts to fix any encountered errors, and the recover switch, which will try to recover what it can if it encounters any bad sectors.

chkdsk [drive:] /F /R

Safely Eject External Drives

While drive ejection is as simple as right-clicking on the drive and selecting Eject, sometimes this isn’t possible. For example, you may be stuck in Windows Recovery with no other option than to use the command prompt. What do you do then?

You can use the diskpart command (read: “disk partition”) to eject the drive:

command-prompt-tasks-eject-drive

When diskpart’s specialized prompt is ready, type list volume to get a list of all drives currently recognized by your system. Take note of the drive’s ###, then type select volume [###] according to the drive you want to eject. Make sure you only select drives that are marked “Removable” in the list.

Type remove all dismount to eject the drive and exit to end the specialized prompt. The drive should now be dismounted and safe to remove.

If you have trouble getting the system to recognize the drive again, repeat the process up until you’ve selected the volume, then type assign letter=[letter] to remount the drive. For example, assign letter=I would mount it as an I: drive.

Search File Contents

A handful of tools enable a fast Windows search What Are the Fastest Tools for Windows Desktop Search? What Are the Fastest Tools for Windows Desktop Search? Search is one of the digital tools we take for granted and heavily rely on. Fortunately, Windows comes with a handy search feature. Could third-party tools be better and faster? We made the test. Read More , but many of them are limited in that they only search through file names and not file contents. The findstr command is a simple way to achieve the latter, allowing you to locate files based on the text within those files.

command-prompt-tasks-findstr

This command is the most complex command on this list with over a dozen switches that alter how the search is performed. Too much to go over in a few paragraphs anyway, so here’s a complete overview and a few examples to show how the command can be used.

Change File Associations

As you may already know, Windows associates particular file formats with programs so that those programs are used when said files need to be opened. The assoc command (read: “associate”) is an easy way to view and edit these file assocations.

Typing the command by itself will list all of the known file associations on your system. This can be useful for diagnostic purposes, otherwise it’s a bit too much information to digest at once. What it’s actually useful for is changing file assocations.

To view the association of an extension:

assoc [.ext]

To clear the association of an extension:

assoc [.ext]=

To set the association of an extension to another filetype:

assoc [.ext]=[filetype]

What is a filetype? For that you’ll need to use the ftype command, which lists all of the known filetypes on your system and which programs they’re associated with. So for example, on my system .TXT is associated as a txtfile and that filetype is opened using Notepad.

Final Thoughts

Yes, there are tools that can handle all of the above tasks, but these commands may come in handy if you ever find yourself stuck in a command prompt or needing to write a batch script.

Plus, we’ve only scratched the surface. Make the command prompt even more useful by learning these important commands for all Windows users 15 CMD Commands Every Windows User Should Know 15 CMD Commands Every Windows User Should Know The command prompt is an antiquated tool from an era of text-based input. But some commands remain useful and Windows 8 even added new features. Find out which ones. Read More and reading over our command prompt cheat sheet Windows CMD Commands Windows CMD Commands Read More . One more important task that ought to be mentioned is the ability to install software through the command prompt The Quickest Way To Install Windows Software: From The Command Prompt The Quickest Way To Install Windows Software: From The Command Prompt One simple command from you and software will be downloaded and installed automatically. Magic? No. Chocolatey - the apt-get equivalent for Windows. Read More .

How often do you use the command prompt? Are you comfortable with it or does it intimidate you? Share your thoughts and questions with us in the comments below!

  1. John M
    August 11, 2016 at 7:01 pm

    Has anyone used "Robocopy.exe"

  2. John M
    August 11, 2016 at 6:57 pm

    In the early days of the "Desktop" computer, there was no such thing as windows. DOS also referred to as the "Command Line". Windows was an after thought. There were a number of shell programs available, as the initial iteration of Windows 1.0 was. For years if you wanted to get anything done including "applying a fix" "installing new hardware", you needed to be "fluent" in DOS. Starting with Windows 3.1 some idea of the path to Windows as a standalone OS became clearer. Microsoft included in these shells, things like "Program Manager" (aka Start menu / Control Panel) and even a utility called "file explorer" began to take shape.
    Its important to understand, this history of the evolution of the MS OS's from DOS 5.0 to DOS 6.22 and Windows shell companion programs like Windows 3.x. Because most computer users only know "Point and Click" operation, the old DOS environment now referred to as the Windows XP, 7,8.x, Vista and currently Windows 10 "Command line" is a complete mystery. Yet the Windows "Command line" remains a relevant and powerful tool to used for a variety of reasons. Want to fix your "Network" issues Windows has always had a powerful set of networking tools you can use only from the CMD line.
    TRY THIS "C:\> ipconfig /all" you can now view the entire TCP/IP settings for your system. IF you want to get a little more fancy, try this. "C:>\ipconfig /all >> C:\my-ipconfig.txt"
    Next instead of using Windows notepad to open the .txt file, simply type the following at the CMD prompt. "more C:\my-ipconfig.txt" this will allow you to view and explore the file by using the "spacebar".
    So, my effort here is to capitalize on the authors assertions concerning the "CMD line" Here are three things to note.
    1. The Windows CMD line is the most efficient and thorough method for "understanding" and troubleshooting your PC. A plethora of tools and information await being discovered.
    2. The difference between being an "end user" and a "power user" is the command line. Problems that sometimes defy logic can be handled with relative ease.
    3. The command line may be the window to your system's soul. But its also the most efficient "Typing tutor" available (Move over Mavis Beacon) and besides using it in the Windows OS, it can become a "gateway" to learning and understanding LINUX & UNIX.
    C:\>Enjoy!
    "C:\>

  3. Varun Rastogi
    February 28, 2016 at 4:54 pm

    All of this is new to me but
    This was awesome
    Love the chain of links you left
    Will check them out

    • Joel Lee
      March 1, 2016 at 3:07 pm

      Thanks Varun! Glad you found it useful. :)

    • John M
      August 11, 2016 at 6:59 pm

      Try the mini tutorial I gust posted :)

  4. Robert G.
    January 22, 2015 at 11:54 pm

    Instead using xcopy in command line, I prefer FreeFileSync in command line.

    • Joel Lee
      January 23, 2015 at 3:19 pm

      FreeFileSync is a nifty program, but I always assumed it was just for keeping directory structures in sync. How do you use it as an XCOPY substitute?

  5. Victor
    January 22, 2015 at 7:12 pm

    The command prompt saved me when I screwed up my file associations once! I associated the .exe extension with a PDF reader or something stupid like that, I nearly bricked my computer!

    • Joel Lee
      January 23, 2015 at 3:17 pm

      Yikes, that sounds horrible lol. That's exactly the kind of rare but unfortunate scenario where these kinds of commands may come in handy. Thanks a lot for sharing Victor. Seems like knowing the Windows command prompt **can** prove useful even in 2015. :)

  6. Errol Mathams
    January 22, 2015 at 6:23 am

    The XCOPY command (with the /s suffix) is good for extracting particular file types from a folder tree.

    • Shafiq Khan
      January 22, 2015 at 4:15 pm

      Agree, Xcopy is useful ... Also various network commands such as ping, ipconfig, tracert etc.

    • Joel Lee
      January 23, 2015 at 3:15 pm

      Awesome, Errol. That's exactly the kind of task that works well on a command line but maybe not so well with a GUI. For anyone who wants to know how to use it, here's an XCOPY command reference:

      https://technet.microsoft.com/en-us/library/cc771254.aspx

  7. Sam
    January 21, 2015 at 4:42 pm

    Sorry Joel but I'm really not sure any of these are necessary. To run Firefox, I could just hit the Windows key, press F and hit enter. I can do that in well under a second. Or just Windows + 3 (since it's the third shortcut on the taskbar).

    If I hit the Windows key and start typing 'defrag' ('def' or certainly 'defr' would be enough) then the 'proper' defrag tool with the front-end runs.

    For file type associations, hit Windows key and start typing 'associations' ('asso' is actually enough).

    For searching for text in your documents, hit Windows key and start typing that text. Files containing the text will appear in the results (pretty fast if you're using an SSD and especially if the file is in a thoroughly-indexed location like 'my documents').

    Most people will never benefit from using the command line, either in Windows or in Linux / Unix etc. Though Linux still isn't ready for prime time.

    • Joel Lee
      January 21, 2015 at 7:07 pm

      You're right, none of these are exactly necessary. GUIs are great for centralized handling of tasks (such as 'defrag' bringing up the actual defrag GUI) but if you know exactly what you want, typing it as a single command can be faster. In a lot of cases, these command line tips are most useful when trying to write a script for batch processing or automation.

  8. dragonmouth
    January 21, 2015 at 4:21 pm

    Why is learning and using Windows Command Line "good" but Linux Command Line makes Linux "not ready for prime time?"

    • Joel Lee
      January 21, 2015 at 7:11 pm

      If you ask me, learning the command line is smart for all operating systems. The "problem" (in some people's eyes) is that certain flavors of Linux are overly dependant on the command line for troubleshooting whereas Windows can be used to full effect without ever opening a command prompt.

      That alone doesn't make Linux "not ready for prime time" but it is a factor. Personally, I think Linux has trouble with mainstream appeal because society is so entrenched in a Windows mindset and Linux is just so different. The day Linux becomes ready for prime time is the day it figures out how to cross that void.

    • bnjohanson
      February 14, 2015 at 7:16 pm

      ...yet another rhetorical (see: zero value) question from dragonchoker...

Leave a Reply

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