What is Environment Variable and Why do we need it?
Environment Variables contain a value that can change, depending on conditions or on information passed to the program. They are information containers for all applications running on the operating system which helps to set up the software environment.
It provides ease in searching.Instead of going through the entire system, the environment variable contains valuable information about system processes, configuration data, file path, and more.
In Windows to set all the env variable at one go
Create a Bash file using the
.bat
extension egsetenv.bat
.In the bash file use the following syntax for setting the env variable.
setx [variable_name] “[variable_value]”
Here:
[variable_name] - name of the variable you want to enter.
[variable_value] - value for the created variable.
For example, let’s add a APP_NAME with a value “ABC” in bash file:
setx APP_NAME "ABC"
- After creating the bash file To set the env variable in one go We can use the following command in the command prompt
setenv.bat
To set env variable individually
You can set each env by using the following command in command prompt
setx APP_NAME "ABC"
Verify its existence
To verify its existence using Command Prompt. We can use the following command:
Set APP_NAME
// ABC
Or you can see the set env variables through the following path in windows:
Control Panel -> System and Security -> System -> Advance System Setting-> Environment variables
Top comments (1)
Great read!