Console Program Input and Output
Unlike Windows programs that display a window panel with menus and buttons, most programs designed to be run from a command prompt simply type out information line-by-line into the Command Prompt window. These programs are called console programs because they interact through plain-text input and output like old-fashioned programs that ran on a computer's main terminal; back then, the main terminal was often called a console.
The tasklist command is a good example of a console program. If you type tasklist in the Command Prompt window and press Enter, this program displays a list of all programs and services that are currently running on your computer.
Each Command Prompt window has the concept of a current directory, its default folder, which is its starting place when looking for files. Although Windows Explorer displays its current directory in its status and address bars, it's most common for the Command Prompt window to show the current directory name in its prompt, the indicator it prints to tell you it's ready to accept another command.
C:\Users\bknittel>
Whereas you use dialog boxes and menus to tell Windows programs how to modify their behavior, you have to type this information into console programs. The tasklist command is another good example of this. If you want to see the tasks and programs running on the computer named bali, which is connected to my network, following command:
tasklist /s bali /u Administrator
In this command, /s tells tasklist that I want to query the networked computer named bali, and /u indicates that want to use the Administrator logon to get this information. /s and /u are called switches or options. Most console programs display the list of options they accept if you enter /? on their command lines.
Those are the basics. Now, let's look at some of CMD's more involved features.
In this tutorial:
- The CMD Command-Line
- CMD Versus COMMAND
- Running CMD
- Opening a Command Prompt Window with Administrator Privileges
- CMD Options
- Disabling Command Extensions
- Command-Line Processing
- Console Program Input and Output
- Using the Console Window
- I/O Redirection and Pipes
- Copy and Paste in Command Prompt Windows
- Command Editing and the History List
- Name Completion
- Enabling Directory Name Completion
- Multiple Commands on One Line
- Grouping Commands with Parentheses
- Arguments, Commas, and Quotes
- Escaping Special Characters
- Configuring the CMD Program
- The Search Path
- Changing the Path
- Predefined and Virtual Environment Variables
- Setting Default Environment Variables
- Built-in Commands
- Extended Commands
- Listing Files with the Dir Command
- Paginating Long Listings
- Printing Directory Listings
- Sorting Listings
- Locating Alternate File Streams
- Setting Variables with the Set Command
- Conditional Processing with the if Command
- Scanning for Files with the for Command
- Using the for Command's Variable
- Processing Directories
- Numerical for Loop
- Getting More Information