Windows Administration at the Command Line



CHAPTER 1

USING THE COMMAND LINE EFFECTIVELY



The Command Line Made Easy

Some people are of the opinion that the command line works one way. You type in a command and
hope that you got all of the information right and received the correct result, which you then have to
interpret. This entire activity sounds quite difficult, somewhat boring, and error prone to say the least.
You have to wonder why someone would put themselves through all that pain. However, the com-
mand line isn't anything like the scenario just mentioned. Actually, if you know a few simple rules,
using the command line doesn't have to be hard at all. The following sections describe some of the
methods you can use to work at the command line.


Using Utilities Directly

Generally, you'll being using the command line by working with the utilities directly. After all, it's
a little hard to create a batch file or script if you don't know how the command works. However,
using a command doesn't have to be hard. All you need to remember is two simple characters,


/?

.
That command line switch says, "Help me!" The command usually will help by presenting you
with some options for using it.

To open a command line, select the Start

Programs

Accessories

Command Prompt com-
mand. You'll see a command prompt. Whenever you open a command prompt using this method,
it opens in your home directory on the hard drive. Type


TaskList /?

and press Enter. Figure 1.3
shows what you'll see. (I've scrolled back to the top so you can see the major entries.)

Figure 1.3

Make things simple;
ask the command for
usage instructions.


The first piece of information is the usage instructions for the command. A set of square brackets (

[]

)
tells you about an optional input. In this case, everything is optional; you can use TaskList by itself.
A slash (

/

) tells you about a command line switch. Sometimes command line switches appear
with a dash (

-

) instead. In either case, a command line switch configures the command to perform
a task in a specific way. For example, TaskList doesn't normally display services, but you can tell
it to display services by adding the


/SVC

command line switch.
Some command line switches depend on other command line switches. You'll see the command
line switches nested within multiple layers of square brackets in this situation. For example, if you
want to supply a password for logging into a remote system to view the tasks running on it, you
must also supply the


/System

and

/Username

command line switches.
In other cases, command line switches are mutually exclusive. The command line will separate
these switches with the pipe (

|

) symbol. The

TaskList

command won't allow you to use the

/M


command line switch with the /

SVC

switch; you must select one or the other.
After the usage information, you'll normally see a description section for newer commands. The
description tells you what task the command performs and why you would want to use it. Sometimes
this information is quite complete, as it is with the


TaskList

command, and in other cases, you'll still