What are System and User Variables in Windows

Υπάρχουν μερικά σημεία ρύθμισης στα Windows που για τους απλούς καθημερινούς are quite complex. But the more we deepen our knowledge and look for specialized programs, the more chances we have of falling on them. Like System and User Environment 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 , 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.

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 they can acquire όσοι θέλουν, όπως το "TEMP" ή το "TMP" η οποία είναι η μεταβλητή που δείχνει τον κατάλογο όπου αποθηκεύονται όλα τα προσωρινά αρχεία. Η πιο δημοφιλής μεταβλητή που έχει να κάνει με μία διαδρομή στο δίσκο σας είναι η "PATH" και είναι αυτή που δείχνει τους καταλόγους που περιέχουν εκτελέσιμα αρχεία.

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 break the existing settings 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. There on the right select "Advanced system settings".

variables

3. Στο παράθυρο "Ιδιότητες Συστήματος" που θα ανοίξει και στην καρτέλα "Για προχωρημένους" κάντε κλικ στο κουμπί "Μεταβλητές περιβάλλοντος" που είναι χαμηλά.

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
Path is the most used environment variable. As we mentioned, it shows the directories that contain executable files. After setting the Path variable correctly, you can use these executables from anywhere on the system. Let's try to understand it with an example. Open the environment variables window and look for "Path" in the system variables.

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

Now you can run it from wherever you are and for example open the command prompt and type the name of the executable that was in the folder. You can provide additional switches and parameters if the program supports it. The program will run from the command line without you even being in the directory where the command is physically located. That's 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.087 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.).