Using DOS Commands in Windows 8

Readers who have used personal computers since the DOS days might still wish to enter the occasional DOS command. DOS commands will let you do things you can’t really do in Windows. For example, in those rare instances where you can’t delete a file in Windows, using a DOS erase or del command with the /F switch will often do the trick. You can use the DOS dir command to print filenames from a folder to paper or a text file.

There is one big catch to using commands in Windows 8. User Account Control (UAC) may prevent you from doing things you’d otherwise take for granted. You can get around many of those by using the Run As Administrator option to open the command prompt. Here are two different ways to open the Command Prompt window:

  • From the desktop, press Windows+X and click Command Prompt.
  • Display the Charms Bar, click Search, and type cmd. Choose cmd.exe or right-click cmd.exe and choose Run As Administrator (see Figure 39.6).

    FIGURE 39.6 Open Command Prompt

    image

The Command Prompt window that opens is much like DOS. By default, you’re taken to the home directory for your user account. But you can navigate around using the DOS cd command. For example, enter cd.. to go to the parent directory, or cd “program files” to go to the Program Files folders.

To see a list of all supported commands, enter help at the command prompt. For the syntax of a command, type the command followed by /?. For example, entering dir /? displays the help for the dir command.


Note
You can change the height and width of the Command Prompt window. To do so, click its control menu in the upper-left corner and choose Properties.

You can copy-and-paste a lengthy pathname to a cd command to simplify opening that folder in a DOS window. In Windows, open the folder in File Explorer, highlight the path in the address bar as in Figure 39.7, and press Ctrl+C to copy it.

FIGURE 39.7 Select a directory path

image

Tip
To see the name you need to type to launch any program, right-click the program’s icon on the All Programs menu and choose Properties. The filename at the end of the Target path is the name you type in the Search or Run box.

In the Command Prompt window, type cd and a space. Then right-click the Command Prompt window and choose Paste. Press Enter, and you’ll be in that folder.

Use the dir command with various switches to view, or optionally print, all the filenames in a folder and also its subfolders if you like. For example, let’s say you navigate to the Music folder for your account (C:UsersyourUserNameMusic). From that folder, entering dir /s lists all file and folder names for all artists, albums, and songs in your Music folder.

You can use the /b, /n/, and /w switches to choose how you want the information displayed. For example, entering dir /s /w. shows filenames in the wide format.

To send dir output directly to the printer, try dir /s /w > prn. You’re probably better off sending the output to a text file rather than straight to the printer. That way you can open and edit the text file before you print or even import it into Excel or Access to make it more like tabular data. To send output to a file, end the command with a filename (or path and filename). For example, entering

dir /s /w >MyMusic.txt

from the Music folder puts the output listing in a file named MyMusic.txt in the Music folder. You can then open that file with any text editor or word processor to clean it up. If you have database management skills, you can import the data to Access or a similar program and treat it like any other tabular data.


Caution
This section is just a side topic for people who are already familiar with DOS. Don’t experiment with DOS commands carelessly. You could lose a lot of files and have no means of getting them back!

To exit the Command Prompt window, enter the exit command or just close its window.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.188.152.157