freed
Mac OS Tutorials
Windows Vista
Linux

Aug
28th

Win. Vista: Using the Command Line – Command Prompt

Files under Windows Vista

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 you press the Enter key. After the command has completed, a new prompt is shown, allowing you to type additional commands.

To run the Command Prompt, type:

cmd

at Start Search or in the Address Bar of Windows Explorer.

Some commands are fairly rudimentary, requiring only that you type their names. Other commands are more involved and can require several options (sometimes called arguments or command-line parameters). For example, you use the del command to delete one or more files; it requires that you specify the name of the file 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 (it requires confirmation before it will delete each file). The fact that this usage is not limited to internal command prompt commands (such as del) is what makes the command line (but not necessarily the Command Prompt application) such an important part of Windows Vista’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  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  or in a folder specified in the path .

Specifying a filename as an argument when launching Notepad (such as myfile.txt in the preceding example) from the Command Prompt instructs Notepad to open that file. Because 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 usually 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 bar) 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, or press F7 to have an old-school character-mode menu pop up with your entire command history.

Figure 14-1. Setting options for the Command Prompt

windowsvista_1401

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), you can highlight text at any time with the mouse, copy it to the Clipboard by pressing Enter, and paste it 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.


Tags: , ,