❘
209 As you can see from Figure 10-6, environment variables appear as a name/value pair. An environment
variable with a specific name has a certain value. Some environment variables in this list are common
to all Windows machines. For example, the system wouldn’t be able to find applications without the
Path
environment variable. Environment variables such as
COMPUTERNAME
and
USERNAME
can prove
helpful for your applications. You can also discover facts such as the processor type and system drive
using environment variables.
It’s possible to create environment variables using a number of techniques. However, the method used
to create the environment variable determines its scope (personal or global), visibility (command prompt
only or command prompt and Windows application), and longevity (session or permanent). For exam-
ple, if you type
Set MyVar=Hello
(notice that there are no quotes for the value) and press Enter, you cre-
ate a personal environment variable that lasts for the current session and is visible only in the command
prompt window. You can see any environment variable by typing
Echo %
VarName %
and pressing Enter.
Try it out with
MyVar
. Type
Echo %MyVar%
and press Enter to see the output shown in Figure 10-7.
FIgURE 10-7: Use the Echo command to see environment variable content.
The most common way to set a permanent environ-
ment variable is to click Environment Variables on
the Advanced tab of the System Properties dialog box.
You see the Environment Variables dialog box shown
in Figure 10-8. This dialog box has two environment
variable settings areas. The upper area manages per-
sonal settings that affect just one person — the current
user. The lower area manages environment variables
that affect everyone who uses the system.
To create a new environment variable, simply click
New. You see the New User Variable (shown in
Figure 10-9) or the New System Variable dialog box.
In both cases, you type an environment variable name
in the Variable Name field and an environment vari-
able value in the Variable Value field. Click OK and
you see the environment variable added to the appro-
priate list. Editing an environment variable is just as
easy. Simply highlight the environment variable you
want to change in the list and click Edit. You’ll see a
dialog box similar to the one shown in Figure 10-9
where you can change the environment variable value.
To remove an environment variable, simply highlight
its entry in the list and click Delete.
FIgURE 10-8: Personal environment variables
affect just one person; system environment
variables affect everyone.
548592c10.indd 209
2/24/10 12:48:31 PM
www.finebook.ir