In this article, we will learn how to set Environment variables in Windows 10 and how to get its value.
- Set Environment Variable :
- pressing the Windows and R key on your keyboard at the same time to open Run and type sysdm.cpl into the input and press Enter or click Ok.
-
- In the System Properties window, click on the Advanced tab and then on the Environment Variables button in the bottom right of the window.
-
- Create a user-specific variable by clicking the New button below the user-specific section.
- In the prompt, you can now set the name of your variable as well as the value. Create a new variable with the name MY_NAME_IS and write your name in the value. Press Ok in the prompt to create the variable, followed by Ok on the Environment Variables window. Variable is now set successfully.
- Get Environment Variable Value :
- Open Command Prompt by pressing Windows + R and typing cmd and click ok.
- write the following code and hit enter :
echo %MY_NAME_IS%
- This will print the value that you saved in the environment variable.