Tips from the Windows Pros: Getting More Out of the Command Prompt with Command Extensions


If you grew up with MS-DOS, like I did, you might find that even Windows XP's many enhancements to Windows aren't enough to keep you out of command-prompt-land permanently.

Believe it or not, you still can't make a printout of the files and folders stored in a given folder from Windows Explorer. And, when it comes to switching drives and folders, the command is quicker than the mouse.

If you want to move around your system faster than Explorer can do it, take advantage of the enhancements to Prompt provided by the Command Extensions activated by default with Windows XP Professional.

Command Extensions make lots of your favorite command-line utilities a lot more powerful in Windows XP Professional than they were in Windows 9x/Me.

Command extensions can be turned off by typing the command cmd /y and pressing Enter at a command prompt. To turn them back on again, type cmd /x and press Enter.

Commands Affected by Command Extensions

When command extensions are enabled, the following commands have new features or are available for use:

  • assoc [*]

    [*] Commands available only when command extensions are enabled.

  • call

  • cd or chdir

  • color [*]

  • del or erase

  • endlocal

  • for

  • ftype [*]

  • goto

  • if

  • md or mkdir

  • popd

  • prompt

  • pushd

  • set

  • setlocal

  • shift

  • start

If you like to write batch files, you'll find that changes to the FOR command alone will make your head spin with possibilities. Type help for >x & notepad x to read all about it.

In the following sections, you'll see how to use some of the other enhanced commands to get more done at the command-prompt level.

TIP

For a list of valid commands at the command prompt, type help | more and press Enter.


Command Extensions Make cd (Change Directory) Easier

The cd (Change Directory) and md (Make Directory) commands allow you to change to a different folder and make a new folder from the command prompt as an alternative to using Windows Explorer.

When command extensions are enabled, you can change to a long directory (folder) without putting quote marks around the name:

 cd \My Documents\My Music\My MP3s 

Without command extensions, you'd need to enter the following command:

 cd "\My Documents\My Music\My MP3s" 

Forget the quotes, and you'd see an error message.

Normally, md (Make Directory) can create just one folder (directory) at a time. When command extensions are enabled, you can create a nested series of folders with a single command. For example, this single command creates a series of folders below your current folder. You could use a command like this within the \My Documents folder to create folders for your home budget:

 md "My Budget\4th Quarter\Travel" 

(Yes, you need the quote marks!)

Command Extensions Make PROMPT More Powerful

When you open a command-prompt session in Windows XP, the default prompt $p$g uses $p (current drive and path) and $g (greater-than sign) to display your current location:

 C:\Documents and Settings\All Users> 

However, if you've mapped a network drive to a drive letter, either with Windows Explorer or the command-prompt NET USE command, all you normally see is a drive letter when you change to the network drive:

 S:\> 

When command extensions are enabled, you can use the following prompt command to display the server name (if any):

 prompt $m$p$g 

Now, the prompt will display the true network path and the drive letter you're using to access it.

Figure 25.16 shows you how this special prompt command makes life easier for you when you work with network drives.

Figure 25.16. Using prompt $m$p$g to display the actual path to a mapped network drive.


Command Extensions Can Change the Color of the Command Prompt Window

Very experienced DOS users might remember when the ANSI.SYS device driver and complex batch file commands were needed to change the screen color in a command-prompt session. When command extensions are enabled, you can use the COLOR command to do the same thing. And, if you want to use more than one command-line session at the same time, you can color-code each one.

To see a complete list of the color codes you can use, type color /? and press Enter.

Here are two examples:

To change the color of the screen to light blue and the text to light aqua (very easy on the eyes), enter color 9B.

To reset the screen color to its original colors, enter color by itself.

The color command affects on only the current command prompt window. If you later open a new window, the colors are reset to the defaults set on the Color tab of the command prompt window's properties page.



Special Edition Using Microsoft Windows XP Professional
Special Edition Using Microsoft Windows XP Professional (3rd Edition)
ISBN: 0789732807
EAN: 2147483647
Year: 2003
Pages: 450

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net