How To Set Environment Variable in Windows 10

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.
      run sytem properties

 

    • In the System Properties window, click on the Advanced tab and then on the Environment Variables button in the bottom right of the window.

system properties advanced

 

    • Create a user-specific variable by clicking the New button below the user-specific section.environment variables
    • 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.
      add environment variable

 

  • 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%

      get environment variable value

    • This will print the value that you saved in the environment variable.

Submit a Comment

Your email address will not be published. Required fields are marked *

Subscribe

Select Categories