Monday, September 18, 2017

What are environment variables in Windows?

Environment variables are, in short, variables that describe the environment in which programs run. They are used by all kinds of programs to answer questions like: What is the name of the computer where I am installed? What is the name of the user account that is running me? What is my current working directory? Where is Windows installed? Where are the temporary files stored on this computer? Where is the OneDrive folder for this user account?

In Windows, environment variables have a name and value. For example, the variable windir (short for "Windows directory") may have the value "C:\Windows" or another path where Windows is installed.

Another common variable is named PATH. Many programs need to know where to find certain files, and the PATH variable tells them where they can find what they need. Those programs look for a PATH variable automatically, so you don’t have to type it all in every time you run the program. This variable has a value consisting of many user directories. These directories are set by the different programs that are installed on the computer, and they vary widely from system to system.

The concept of environment variables exists in most operating systems, from Linux to OS X to Windows. In principle, they mean the same thing but the way they are implemented and used differs.




Types of environment variables: User and System

There are two types of variables: user variables, specific to each user account, and system variables that apply to all user accounts.

User environment variables have values that differ from user to user. As their name implies, they are specific to your user account, and they store user specific data, like the location of your user profile, the folder where temporary files are stored for your account, the location of your OneDrive folder, and so on. They can be edited by that user account but not by other user accounts. These variables can be set by the user, by Windows or by different programs working with user specific locations.

System variables are global and cannot be changed by any user. Their values are the same for all user accounts. They refer to locations of critical system resources, like the folder where Windows is installed, the location of Program Files, and so on. These variables are set by Windows, by different programs and drivers.




How to find the environment variables in Windows

In Windows 10, use Cortana’s search box and type environment. Then, click or tap on the “Edit the system environment variables” search result.

In Windows 7, type environment in the Start Menu search box and two search results are displayed: “Edit environment variables for your account” and “Edit the system environment variables.” Click on either of them.

In Windows 8.1, type the word environment while on the Start screen, and two search results are displayed: “Edit environment variables for your account” and “Edit the system environment variables.” Click or tap either of them

The Environment Variables window is opened. There are some minor visual differences between Windows versions.The options and buttons available are the same and work the same way, no matter which Windows version you are using.




How to access the environment variables from the Control Panel





How to access the environment variables from the Run window




How to view environment variables in the Command Prompt

Open cmd then type command: SET, without any other parameters, and press Enter.



How to view environment variables in the PowerShell

Open it, type the command Get-ChildItem Env: then press Enter.



Conclusion

As you can see from this tutorial, environment variables are neither easy to find nor visible in any way, while working with Windows programs. They are managed in the background by the operating system and the different programs and drivers you install. However, they are essential to the proper operation of the operating system and of your installed apps. If you change the value of important system variables, without knowing what you are doing, you will get to experience just how important these environment variables are, by causing your system to malfunction

No comments:

Post a Comment