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

The Environment Variable ) is what these two words literally mean. It is a variable in a particular environment. That is, it 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 obtain some critical information about it . And when we say prices we are not talking about numbers and figures but about alphanumeric elements.

Like 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 explorer 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.

To be able to run a program from the Command Prompt ( Prompt) από οποιοδήποτε κατάλογο, θα πρέπει αυτό το πρόγραμμα να έχει το εκτελέσιμο .exe 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".

variables

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 should press it to see all these prices.

Using the Path variable

path
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 yet. 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

That was pretty much the basics of system variables and user variables in Windows. Windows comes with a lot more variables, so don't forget to check them using the 'SET' command.

iGuRu.gr The Best Technology Site in Greecefgns

every publication, directly to your inbox

Join the 2.100 registrants.
enviroment, Windows, Dynamic, cmd, variables

Written by Dimitris

Dimitris hates on Mondays .....

2 Comments

Leave a Reply
    • Thanks for the reply. It is our pleasure to see comments that supplement or correct our articles.
      It would be to the benefit of all readers, but also of the authors, if you continued your reasoning and mentioned additional benefits and uses of the path.

Leave a reply

Your email address is not published. Required fields are mentioned with *

Your message will not be published if:
1. Contains insulting, defamatory, racist, offensive or inappropriate comments.
2. Causes harm to minors.
3. It interferes with the privacy and individual and social rights of other users.
4. Advertises products or services or websites.
5. Contains personal information (address, phone, etc.).