Tuesday, November 11, 2014

Windows command prompt tips and tricks

Even though DOS is an operating system of the past for most people, it still lives on in the form of the Windows command prompt.  There are many things you can do from the command prompt -- some of which are simpler to do from there than by going through Windows' graphical interface.

If you use the command prompt often, there are many little tips that will make the command prompt easier to use.  For example, when you are typing out a path or a file name, you can abbreviate the name if it is longer than eight characters.  Instead of typing "CD\program files" you could type "CD\progra~1" and save yourself some time.  This may not seem like much of a tip, but it comes in handy when you type a lot of long file names.  The "~1" is used to truncate the file or directory name, so you only need to type the first six characters.

Older versions of DOS did not allow you to use spaces as part of a file name, but newer versions do.  Sometimes when you try to run DOS commands, the spaces will confuse the system, causing the command to not be performed or to be performed incorrectly.  To avoid this problem, use quotes when typing file or directory names, like this:

DEL "test file.dat"

Without the quotes, some commands will look at the second part of the name as a switch or parameter, rather than part of the file name.

There are several DOS commands that display or list information, including DIR and IPCONFIG.  It can be a hassle to have to scroll back up to read information that you missed.  With DIR, you can use the "/p" switch to display one page's worth of info at a time, but other commands don't have this option.  However, you can use the universal "|more" switch.

After any command that displays a lot of information (such as "IPCONFIG /all") add the pipe symbol (|) by pressing <SHIFT> and the backslash (\) and then type "more".  So your command would look like this:

IPCONFIG /all |more

The information displayed by the command will be shown one page at a time.  You can either press the space bar when the system pauses, to display another page's worth of data, or you can press the <ENTER> key to advance the data one line at a time.  The "|more" switch can be used immediately after a command, or with a space in between.

(Originally posted on Helium.com, July 2010)

No comments:

Post a Comment