Using the Command Prompt
The Command Prompt is Microsoft’s version of a command-line interpreter or CLI. Some people refer to it as DOS because of its similarity to the DOS command-line. However, the Command Prompt is a Windows entity. The beauty of the Command Prompt is that you can navigate to and configure just about anything in text. Just about anything than can be done in Windows can be done in the Command Prompt.
This article shows how to open the Command Prompt, configure it to your liking, and then explains some of the basics of how to use it.
How to open the Command Prompt
The Command Prompt can be opened in a variety of ways, which will depend on the version of Windows you are using. For example, in Windows 7, you would click Start > All Programs > Accessories > Command Prompt. Another way to access it would be to click Start > Run, then type cmd.exe. Depending on your version of Windows, the Run prompt might not show up in your Start menu, but you can easily access it by pressing the Windows + R keys together. If you need to run the Command Prompt as an Administrator, click Start > All Programs > Accessories, and right-click Command Prompt and select Run as Administrator.
Of course these are only a few of the ways you could open the program; do whatever is fastest for you!
Once you have the Command Prompt open, it will look something similar to Figure 1:
Figure 1 Example of Windows 7 Command Prompt
In Windows 7, by default, this places you in the C:\Users\%username% folder. %username% is whatever user you are logged in as. If you ran the Command Prompt as an administrator, the path you are placed in would be C:\Windows\system32. You can also tell the difference by looking at the title bar of the Command Prompt. If you are running the Command Prompt as an administrator, it will say “Administrator: Command Prompt” in the title bar.
Configuring the Command Prompt to your liking
The initial look of the Command Prompt may be a bit hard on the eyes. With its standard black background and small text, you might wish to modify it. Let’s make it a white background with black text, and increase the size of the text a bit.
In this step-by-step, we will use the Windows 7 Command Prompt.
- Open the Command Prompt.
- Right-click the title bar and select Properties. This displays the Command Prompt Properties dialog box.
- Click the Font tab, and select 12X16 in the Size area. This should noticeably change the size of the text which you can see in the “Selected Font: Terminal” area.
- Click the Colors tab, and select the white color box to change the screen background.
- Next, click Screen Text, and select the black color box to change the screen text. This should give you a white background with black lettering, as shown in the “Selected Screen Colors” area. An example of this is shown in Figure 2. Of course, feel free to select whatever colors you like[md]even the old school Commodore 64 blue on blue!
Figure 2 Example of a Modified Windows 7 Command Prompt
You can also change the size of the window in the layout tab, as well as how much history will be remembered by the Command Prompt. Use these options to configure a Command Prompt that displays what you want in a pleasing fashion.
Using the Command Prompt
Now let’s talk some of the basics when it comes to using the Command Prompt. I’ll delve into three areas: navigation of the operating system, how to ping another computer on the network, and the creation of batch files.
Navigation
Navigating the operating system is done with the CD command. You can go anywhere in the directory tree with this command. (By the way, “directories” and “folders” are synonymous.)
For example, in Figure 2 I am currently located in the C:\Users\Lamprocles path. (Lamprocles is one of my silly usernames.) If you wanted to go to the root of C in one fell swoop, you could easily do this by typing CD \, as shown in Figure 3.
Figure 3 Use of the CD \ Command
To return to the folder we were at before, we could type CD \users\lamprocles. It works in this manner regardless of what folder you want to access. Any folder in any path can be accessed in this way; just be sure to remember the root \ in the beginning of each path. To see commands that you typed previously, press the Up arrow on the keyboard. You will be able to scroll back and forth through the commands you used, and it makes for a nice timesaver.
Pinging
To find out if another computer on the network is “alive” or available to you for communication, you can use the ping command. Ping reaches out to the remote computer and returns results based on whether it finds the computer. For example, if your computer had the IP address of 192.168.1.1 and a second computer on the network had the IP address 192.168.1.2, you could verify the existence of that second computer on the network by typing ping 192.168.1.2. After pressing Enter, you should receive replies. If you do not, the computer is not available on the network, or your computer is not accessing the network properly. You could also use this command to ping your router, other computers on the network, even websites. Try pinging my personal website with the following command: ping davidlprowse.com.
Batch Files
Batch files are files that contain one or more commands. These files can be executed to produce one or more results without having to open the Command Prompt. For example, let’s say you wanted to ping another computer every day but didn’t want to go through the hassle of opening the Command Prompt, typing the command, and waiting for the answers. You could create a batch file that would automate the process. To do so you would open a new file in Notepad (this can be opened by accessing the Run prompt and typing notepad), and create the batch file by typing ping 192.168.1.2 for example. Then you would select File > Save As. Next, Click the Save as type drop-down menu and select All Files. Then name the file (for example, ping.bat). Note the .bat extension. Save the file to your desktop or wherever you like.
Afterwards, to run the file, you double-click it. In Windows 7 and Vista you would need to right-click it and select Run as administrator in order for it to work properly. This automatically opens the Command Prompt (our modified version with new colors and font size), starts the ping, and awaits replies from the host, 4 in total. Plus, you can do this with just about any command, or groups of commands. Also, the batch file can output the results to text files or to printers. Automation saves you time, and batch files can be very instrumental when it comes to automation. In 32-bit Windows versions, you can even create the batch files from within the Command Prompt by using the edit command. However, this is not available by default in 64-bit versions, and would have to be added to an existing Windows 64-bit installation.