Section 6.1. Using the Command Line

6.1. Using the Command Line

The premise of the command prompt is simple enough: commands are typed, one at a time, at a blinking cursor. The commands are then issued when the Enter key is pressed. After the command has completed, a new prompt is shown, allowing additional commands to be typed.

Some commands are fairly rudimentary, requiring only that you type their name . Other commands are more involved and can require several options (sometimes called arguments or command-line parameters). For example, the del command (discussed later in this chapter) is used to delete one or more files; it requires that the name of the file be specified after the command, like this:

 del /p myfile.txt 

Here, myfile.txt is the filename to be deleted and /p is an extra option used to modify the behavior of del . The fact that this usage is not limited to internal commands (like del ) is what makes the command line (but not necessarily the Command Prompt application) such an important part of Windows XP's design. For example:

 notepad myfile.txt 

is what Windows executes behind the scenes, by default, when you double-click the myfile.txt icon in Explorer. Notepad (discussed in Chapter 4) is effectively a "command" here. If you type the filename of any existing file at the command prompt, it instructs Windows to launch that file. This works for applications, Windows Shortcuts, batch files, documents, or any other type of file; the only requirement is that the file be located in the current working directory (see "cd or chdir", later in this chapter) or in a folder specified in the path (also discussed later in this chapter).

Specifying a filename as an argument when launching Notepad (such as myfile.txt in the example above) from the command prompt instructs Notepad to open that file. Throughout this book, you'll see references to a component's command-line syntax that documents these otherwise hidden features. Since every program and command has its own set of command-line options, it's best to get a feel for the way they work in general rather than trying to commit them all to memory.

If you've executed a command that takes a long time to complete, such as one that displays a great deal of information on the screen, you can interrupt it by pressing Ctrl-C.

Open the control menu of any open Command Prompt window (click the little icon in the top left of the window or press Alt-Space) and select Properties to customize the look and feel of the command prompt window. An important option here is Layout Screen Buffer Size Height, which controls the number of lines kept in memory; this enables you to scroll up to view a history of your entire session. This is useful, for example, if you're looking at long directory listings. Note that this is not the same as Options Buffer Size, which contains a "most frequently used" list of typed commands; use the up-and-down arrow keys at the prompt to cycle through them.

Copy and paste operations are also possible at the Command Prompt, but not using the traditional keyboard shortcuts: Ctrl-X, Ctrl-C, and Ctrl-V won't work here. If QuickEdit is enabled (Properties Options QuickEdit mode), text can be highlighted at any time with the mouse, copied to the clipboard by pressing Enter, and pasted by clicking anywhere in the window with the right mouse button. If QuickEdit is disabled (the default), right-clicking will display the Edit menu; select Mark to begin highlighting text and then go to Edit Copy or simply press Enter to copy the text to the clipboard.

Finally, the prompt itself, known as the caret ( > ), is usually accompanied by a folder name representing the current working directory. Note that the term "directory" is synonymous with "folder," and is used throughout this chapter only because it is customary when discussing the command prompt.

See "Command Prompt" in Chapter 4 for more information on the cmd.exe application and its command-line parameters. Of special interest is the /e parameter, which enables or disables "command extensions," additional features documented throughout this chapter.



Windows XP in a Nutshell
Windows XP in a Nutshell, Second Edition
ISBN: 0596009003
EAN: 2147483647
Year: 2003
Pages: 266

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