twitterfacebookgoogle plusrss feed

Pages

Friday, February 11, 2011

Add Environment Variables to Windows path

Existing variables can be edited or deleted and new ones can be added in several ways. For temporary changes, the command " Set" can be used in scripts or in a command window. An example is shown below:

set temp=C:\temp

Here, the %TEMP% directory has been changed from the default value. Note that the there must be no spaces on either side of the "equals" sign. Changes made with "Set" disappear when the command window is closed, thus rendering this method fairly uninteresting for the average PC user. A more usefulapplication of "Set" is to list the environment variables. Open a command window and enter "set" to see what the variables are on your system. Those who wish can consult this Microsoft article for more details about "Set".

Adding or Editing Environment Variables

A more permanent way to manage environment variables is provided in the System Properties dialog box. Open Control Panel > Performance and Maintenance > System (or right-click on My Computer and choose "Properties"). In the box that opens, click the "Advanced" tab to obtain the dialog box shown below. Next, click the button "Environment Variables".


The figure below shows the "Environment Variables" dialog box that opens next. It lists two kinds of variable- those that apply only to the current user and those that apply to the whole system. You can simply scroll down the lists to see what is on your system or you can edit the lists. Note that I have created a user variable %BACKUP% that gives the path to my one of my backup directories. That makes it easier for me to write a backup script since all I have to do is enter %BACKUP% whenever I want to refer to this directory. To create a new variable, use the "New" button. There are also buttons for editing and for deleting variables.

The box for adding a new user variable is shown below. Generally, this is likely to be a directory that you use frequently but can be any string of less than 8192 bytes. The maximum total size for all environment variables, including variable names and the "equals" sign, is 32767 characters.

The previous figure shows a box for editing a variable; in this case it is the PATH variable. Be sure to remember to separate directory names with a semicolon. If you use programs in a particular directory a great deal, you may wish to add it to the path. The figure shows that the directory "C:\PHP" has been added, it helps system to understand PHP files on Windows plat form.


0 comments:

Post a Comment

comment or ask