What is PATH in environment variables and how to change it

[Windows]

Every process need to do some tasks like to create temporary files, execute some files, store some data etc. Environment variables are set of values that defines default location for these tasks. So whenever a process requires to create a temp file, it looks to environment variable and see the location given by it. 
Environment variables are a set of dynamic named values that can affect the way running processes will behave on a computer. They are part of the environment in which a process runs. For example, a running process can query the value of the TEMP environment variable to discover a suitable location to store temporary files, or the HOME or USERPROFILE variable to find the directory structure owned by the user running the process.[1]



Every process has an environment block that contains a set of environment variables and their values. There are two types of environment variables: user environment variables (set for each user) and system environment variables (set for everyone). By default, a child process inherits the environment variables of its parent process. Programs started by the command processor inherit the command processor's environment variables. To specify a different environment for a child process, create a new environment block and pass a pointer to it as a parameter to the CreateProcess function. The command processor provides the set command to display its environment block or to create new environment variables. You can also view or modify the environment variables by selecting System from theControl Panel, selecting Advanced system settings, and clicking Environment VariablesEach environment block contains the environment variables in the following format:
Var1=Value1\0
Var2=Value2\0
Var3=Value3\0
...
VarN=ValueN\0\0
The name of an environment variable cannot include an equal sign (=). [2]
There are a lot of environment variables like temp Path etc but here we are interested only in PATH.

PATH:

Path is a system environment variable that specifies locations where executable files are located. Like if a program contains .c file, it will look from path variable the directory of gcc or some similar software and it will use that files to run this file. Otherwise program have to search whole C:/ disk thereby wasting processing power. 
In windows, it is some directories separated by semicolons (;). First entry is mostly C:\WINDOWS\system32

How to change PATH:

Some time we need to change path variable such as when you use some IDE for programming language  you also need its compiler. Suppose you have installed a c compiler such as GCC or CyGwin but you haven't  added it into path variable then you compiler will not compile you program. In this case you have to edit this variable. So here is how to change it.

Step 1: Open system System Environment

Search in Start of windows
 Click open Environment variables



A window like this will open

Step 2: Edit Path

In system variables, find Path and click edit below.


A window like this will open

 Now add address of the folder where your program is installed
Warring: Just add new address followed by a semicolon ;. Don't delete anything else.



References:

No comments:

Post a Comment

Thank you for your response.