What are System and User Variables in Windows

There are some setups in Windows that are quite complicated for ordinary everyday users. But the more we deepen our knowledge and look for specialized programs, the more chances we have to fall on them. Such as System Environment and User Variables.

What is it and what do they do?

variables 4

In this article we will discuss environment variables, system and user variables and how to add and modify them. Next, we will go to the dynamic system variables and see how to use them in the command line. So tie up, the flight begins.

What is an Environment Variable

Environment Variables is what these two words literally say. It is a variable in a specific environment. That is a value that can changed and which differs from computer to computer.

Windows provides one environment for applications, which will install themselves in this environment and perform operations and that is what makes the second word. Combining both of these words, environment variables are those objects that store values ​​provided by the environment.

In short, we say that the environment provides values ​​that help other programs to obtain some critical information about the system. And when we say values ​​we are not talking about numbers but about alphanumeric elements.

For example the environment variable called 'windir' which corresponds to the directory where Windows is installed. To understand what this environment variable does, open an exploration window and type %windir% in the address bar. It will take you directly to the Windows installation folder.

So having the variable windir as the folder path where Windows is installed gives third-party programmers the right to use windir whenever they want to go there, without having to know if your Windows is installed on disk. C: or D: or in the C: / Windows folder or in the F: / Mitsos folder.

There are many other variables that can be accessed by anyone, such as "TEMP" or "TMP" which is the variable that shows the directory where all temporary files are stored. The most popular variable that has to do with a path to your disk is "PATH" and it is the one that shows the directories that contain executable files.

Before you can run a Command Prompt program from any directory, that program must have the .exe executable in the Path variable. That is, you install a programming language, let's say python. In order to be able to run a python command from anywhere on the command line, the Path must have, among other things, the physical path where the program is stored.

All of these variables become very convenient when you develop something or use the shell a lot.

What are System Variables and what are User Variables?

Very similar to how the registry works in Windows, we also have the System Variables (System variables) and User Variables (System variables). System variables are system-wide and do not differ from user to user. While User Variables are configured differently from user to user. You can add your variables below each user so that they are not affected by other users using the same computer.

User Variables have a higher value than System Variables. So if there are user variables with the same name as the system variables, then the user variables will be taken into account. Except for the Path variable which works differently. The Path User Variable is attached to the System Variable. Thus, the order of entries will be the system entries followed by user entries.

How to add and modify environment variables

A little warning before we go deeper. Create a system restore point and try not to violate existing settings that have been made for your system. Until you are sure of your actions. To open the Environment Variables window, follow these steps:

1. Open Settings> System> Info.
2. On the right, select "Advanced System Settings".


3. In the "System Properties" window that will open and on the "Advanced" tab, click the "Environment Variables" button that is low.

A new window with environment variables will open showing you the user and system variables separately.

variables 1

The variable name is in the first column and its value is in the second. The corresponding buttons below the table allow you to add, edit and delete these variables.

variables 2

When a variable has many values ​​you must click edit to see all of these values.

Using the Path variable

Path is the most widely used environment variable. As mentioned, it shows the directories that contain executable files. Once you have properly configured the Path variable, you can use these executables from anywhere in the system. Let's try to understand it with an example. Open the Environment Variables window and look for the "Path" in the system variables.

Click 'Edit' and then click 'Create' without playing with any other controls. Now click on "Browse" to browse and select a folder that has the desired executable file. Click the "Ok" button and save everything.

Now you can run your application from wherever you are and for example open the command prompt and enter the name of the executable file that was in the folder. You can provide additional switches and settings if the program supports it. The program will run from the command line without even being in the directory where the command is located. This is the beauty of the Path variable.

List of all environment variables

Open the command prompt and type set and press Enter. The full list of variables with their current values ​​will be displayed and you can refer to whichever you want to make changes to your computer.

cmd set

Of course you can see the variables one by one, from the Environment Variables window we mentioned earlier, but with the command line things are more concentrated. Anyway, whatever suits you.

Dynamic Environmental Variables

Unlike conventional variables, dynamic environment variables are provided by CMD and not by the system. That is, they are internal variables of cmd.exe and therefore are used only with the command line. Dynamic variables are not available in other executable files or scripts, as these variables are not essentially environment variables.

You can not change the values ​​of these variables and they extend to different values ​​every time a question is asked. Even the SET command does not reveal these variables.

Some of the dynamic environment variables are:

%CD%: Typing in this command will give you the current directory in which you work.
%DATE%: This variable will give you the current date according to the date format preferences.
%TIME%: Similarly, it gives you the current time according to the time format preferences.
%RANDOM%: This variable prints a random number between 0 and 32767 (type echo% random% on the command line and you will see).
%ERRORLEVEL%: Specifies the error level set by the last execution command.
%CMDEXTVERSION%: This variable indicates the version of the command line extensions.
%CMDCMDLINE%: Shows the path of their cmd.exe utility

This was let's say the basics about system variables and user variables in Windows. Windows comes with many more variables, so be sure to check them using the 'SET' command.

Read them Technology News from all over the world, with the validity of iGuRu.gr

Follow us on Google News iGuRu.gr at Google news