Software Report [Windows Tips: Command Line Control - 08/03/2005]
- From: Ablang <HilaryDuffPerfectWoMan@xxxxxxxxxxxxxxx>
- Date: Fri, 05 Aug 2005 04:56:26 -0700
August 3rd, 2005
Windows Tips: Command Line Control
Contributing Editor Scott Dunn
Some of Windows' most useful tools don't have desktop icons. Nor are
they listed on the Start menu, or even in Control Panel. If you search
for them in the operating system's labyrinth of folders and
subfolders, you probably won't find them. Some don't even exist as
independent files. Instead, you launch these terrific tools by
entering their text commands in Windows' Run box (or at the command,
or DOS, prompt) to perform all sorts of useful tasks quickly. This
chart lists several of my favorites:
http://www.pcworld.com/howto/graphics/121786-2309p146-3b.jpg
Open the window: Usually you'll type the commands in a command window
(which resembles the fabled DOS screen of eons past). To open it in
Windows 98, choose Start, Programs, MS-DOS Prompt. In Windows Me,
click Start, Programs, Accessories, MS-DOS Prompt. In Windows 2000 and
XP, select Start, Programs (All Programs in XP), Accessories, Command
Prompt. Alternatively, you can open the window by choosing Start, Run,
typing command (in Windows 98 and Me) or cmd (in 2000 and XP), and
pressing Enter.
Often you can use commands without opening a prompt window, by
clicking Start, Run and entering the command there. Some can instead
be entered directly in the Address bar of any Explorer or folder
window. For a host of additional tips to simplify your command-line
life, check out the November 2003 "Windows Tips":
http://www.pcworld.com/howto/article/0,aid,112475,tk,srx,00.asp
Stay awake at the switch: While the commands are useful by themselves,
their real power comes from their "switches" (optional codes typed at
the end of the command that vary the function). For almost every
command, the best way to find the appropriate switches is to type the
command name followed by a space and /?. Then press Enter. This
provides you with a summary of the command's purpose, as well as a
description of its syntax (so you'll know which switches to use and in
what order) and an explanation of each switch. In some cases you can
get help by choosing Start, Help and searching for the command name in
question.
Drag to avoid typing: When your command acts on a file or folder (such
as the "attrib.exe" and "compact.exe" commands described below),
generally you must type the path to that folder after the command (if
the folder name isn't already to the left of the prompt). You can save
typing time by doing a little dragging-and-dropping. First, type the
desired name into the command window, followed by a space. Next, open
Windows Explorer or any folder window and select the file or folder
you need. Finally, drag the file or folder from Explorer into the
command window. Windows then types the path for you. If your command
needs a second file name (like the "fc" file-compare command), type
another space, and drag and drop a second file or folder in the
window. For another way to save on typing, see my description of the
"doskey.exe" command below.
Give it a new look: To spiff up the command line, right-click the
title bar of the command window and choose Properties. Under the Font
tab, select the size and style of type you want; this also affects the
size of the command window. In Windows 2000 and XP, you can change the
background color and the text color via the Colors tab, and the
default size of the window by choosing the Layout tab. When you click
OK, Windows gives you the option of applying the changes to the
current window only or to all future command windows as well.
Command Compendium
The chart linked to at the top of this newsletter doesn't include the
basic navigation and file-management commands from the old DOS days:
"dir" lists the files and folders in a directory, "cd" changes the
current directory, "format" "erases" a disk, "md" creates a directory,
"ren" renames a file or folder, "copy" copies the selection, "xcopy"
copies all of the subdirectories as well, "move" puts the item in a
new location, "del" removes it, and "deltree" deletes a directory
along with its subdirectories and files.
cmd.exe (Windows 2000 and XP), command.com (98 and Me): These commands
(you don't need to enter the period and extension) open the window
where you enter the other commands discussed here. Using either one
with the /c switch, you can create a shortcut that opens a command
window, executes a command, and then closes the window. This allows
you to launch a command just by double-clicking its icon or choosing
it from the Start menu. For example, to make an icon that refreshes
your network connection, right-click the desktop or in any folder
window and choose New, Shortcut. In the first box, type cmd /c
ipconfig /renew. Click Next and follow the wizard's instructions to
create the shortcut. If you want the command window to stay open so
that you can see the results of your command, simply replace the "/c"
with /k. You can use this shortcut technique with many of the commands
listed here.
attrib.exe: This command lets you change one or more of a file's
attributes (such as "Hidden," "System," "Read-only," or "Archive").
It's usually easier to right-click the file in an Explorer or folder
window, choose Properties, and check the desired boxes. But when you
need to change attributes for files in multiple subfolders, this
command line (with the /s switch) can do it for you in one step.
compact.exe: If your drive is formatted with the NTFS file system
(available only in Windows 2000 and XP), you have the option of
compressing files and folders by right-clicking them, choosing
Properties, clicking Advanced under the General tab, and selecting the
appropriate check box. But what if some of the files in a folder are
already compressed (such as JPEG photos), while others could benefit
from compressing? Use this command with the /s switch and wild-card
characters to compress only specific files in the selected directory
(and in all its subdirectories). For example, compact /c /s:c:\doc
*.doc will compress all of the Word documents in your Doc folder and
subfolders. To uncompress, change the "/c" to /u.
doskey.exe (Windows 2000 and XP), doskey.com (98 and Me): Once you
enter this command at the prompt, it stays resident in memory, keeping
a list of the commands you type. Just press the up or down arrow keys
on your keyboard while at the prompt to scroll through the commands
you've used in the past. You can also navigate to a command that's
similar to the one you need and then change it as necessary: Move left
or right one character with the arrow keys, or left or right one word
by holding down Ctrl and pressing an arrow key. Make your changes and
press Enter to execute the change. To see all the commands you've
typed since you loaded Doskey, type doskey /history. To clear the
history and start afresh, type doskey /reinstall (or press Alt-F7).
Don't bother using Doskey in Windows Me, 2000, or XP. In these
versions, the command windows already have a built-in buffer to
remember past commands.
ipconfig.exe: This helpful network utility displays your current IP
address, as well as its subnet and gateway addresses. Use the /all
switch to see even more network information. The /renew switch
(/renew_all in Windows 98 and Me) refreshes the connections. (See also
"ping.exe" below.)
openfiles.exe: If you need to figure out who on your network has a
shared file open, type this command at the prompt and press Enter. You
can also use it to close the open files in a shared folder or to
disconnect the user currently viewing them. For details, type
openfiles /disconnect /? at the command prompt.
ping.exe: When your network is experiencing technical difficulties,
this simple troubleshooting utility will tell you whether two
computers are talking to each other. Just type ping, a space, and the
network name or IP address of the problem computer. If it reports a
reply, you'll know that the connection is okay. You can also use this
command to confirm that your own Internet connection is working.
recover.exe: If you lose a file to a corrupt sector on an NTFS disk,
this command restores as much of the lost data as possible. Type
recover followed by a space and the full path and name of the file you
want to resuscitate. No wild-card characters are allowed in the
specified file path, and you can recover only one file at a time when
using this command.
runas.exe: People who log in to a non-administrator Windows account
(which Microsoft recommends for security reasons) may think that they
have to log off and back on to perform administrator-only tasks. Not
so! This command launches a program as if you were another user. Just
type runas /user: followed by the name of the profile under whose
auspices you want to run the application, then a space and the
program's name. (Use the /? switch to get details on the exact form to
use with this command.) You will, of course, be prompted for that
profile's password before the program launches.
sort.exe: To sort the items in a text file alphabetically, type sort,
a space, the name of the file, another space, the greater-than symbol
(>), another space, and the path and name of the file in which the
sorted entries will appear (for example, you might type sort
messylist.txt > neatlist.txt). Add the /r switch at the end if you
want the list to appear in reverse alphabetical order.
taskkill.exe: You could use Windows XP's Task Manager to close any
running application or process, but this utility not only closes one
app, it also lets you stop multiple programs at once via wild cards
and filters. For example, to shut down all applications that are not
responding, type taskkill /fi "status eq not responding". For more
options, consult the help screen.
Get More File-Management Muscle With XXCopy
Windows' xcopy command is useful for copying all the files and folders
in a directory, but its options are limited. XXCopy, a freeware
replacement from Pixelab, adds the ability to copy files with long
names while preserving their short names. The program also includes
features for making backups, synchronizing folders, and more. No lover
of batch files should be without it. XXCopy is free for personal use.
You can download it from PC World:
http://www.pcworld.com/downloads/file_description/0,fid,7995,tk,srx,00.asp
For the skinny on the complicated file names issue, read my April 2001
"Windows Tips":
http://www.pcworld.com/howto/article/0,aid,41242,tk,srx,00.asp
For more tips, plus related news and reviews, visit PC World's Info
Center for Windows at:
http://www.pcworld.com/resource/infocenter/0,ctrid,6,ic,Windows,tk,srx,00.asp
Send Windows-related questions and tips to Scott Dunn at:
scott_dunn*pcworld.com
Read Scott Dunn's regularly published "Windows Tips" columns:
http://www.pcworld.com/resource/columnist/0,colid,31,tk,sr,00.asp
===
"To buy an island is the same as courting a woman. You can never explain exactly why you love her. It's chemistry--something you cannot define--a feeling that you can stay forever."
-- Farhad Vladi, Islands (mag) Jul/Aug 2005
.
- Prev by Date: Re: Test...
- Previous by thread: Re: Test...
- Index(es):