The Command Prompt
Windows provides a command prompt interface that enables you to enter text-based commands or run command-line tools. Command-line tools accept only text input, and they output information either in text format or by opening a graphic display window. You can use command-line equivalents of graphical tools to create batch programs or scripts that automate administrative tasks. Some Administrators and Power Users might also ﬁnd command-line management to be more streamlined and efficient than working through a graphical interface.
Figure: The command Prompt interface.
- The default path in Windows 7 for the prompt is the user proﬁle folder for the current user (C:\Users\username).In Windows XP, the default path is C:\Documents and Settings\username.
- Because you can run DOS-type commands at the command prompt, it is sometimes casually called the “DOS prompt.”
Windows provides several different command interpreters. The typical command prompt interface is the standard Windows command interpreter, available in Windows XP and Windows 7. To access the command prompt interface, you can either run cmd.exe or choose the Command Prompt shortcut from the Accessories menu. Windows XP also includes the DOS command interpreter, command.com, to support running DOS-based applications with an MS-DOS subsystem. There are also the Windows PowerShell and Windows Recovery Console, used for more high-level administrative tasks.
Sample Command-Line Tools
The following table gives some examples of common command-line tools you can use to manage Windows computers.
Because the syntax for a tool might vary slightly between operating systems, you should check online help for the exact syntax. To view online help at the command prompt, enter the command followed by a forward slash and a question mark (for example, format /?). For a list of all the available commands, type help at the command prompt.
Tool, Function and Syntax
Dir – List the contents of a directory (folder).
Syntax: dir [path][switches]
Cd or ChDir – Change to another directory.
Syntax: cd drive:path
Copy – Copy ﬁles.
Syntax: copy source destination
Del or Erase – Delete ﬁles.
Syntax: del filename or erase foldername
Md or MkDir – Create a directory.
Syntax: md foldername or mkdir foldername
Rd or RmDir – Delete a directory.
Syntax: rd foldername or rmdir foldername
Rename or Ren – Rename a ﬁle.
Syntax: rename drive:path oldfilename newfilename
Syntax: ren drive:path oldfilename newfilename
Type – Display the contents of a text ﬁle.
Syntax: type drive:path filename
Ver – Display the operating system version.
Running the Command Prompt
How You Do It
1. Run the command prompt.
a. Choose Start→All Programs→Accessories.
b. Click Command Prompt.
c. Maximize the Command Prompt window.
2. Enter commands at the prompt.
a. To display the current operating system version, enter ver
b. To change to the root of the current drive, enter cd \
c. To see the contents of the current folder, enter dir
3. Create a folder using the command prompt.
a. At the C:\> prompt, enter md LocalData
b. To verify that the folder is created, enter dir
c. To close the Command Prompt window, enter the command exit