How to Set Environment Variables in Windows 10 - Helpful Guide

People are currently reading this guide.

Environment variables store values related to the current environment, such as the operating system or the user's session. Path Environment Variable is one of the most famous is called PATH in Windows, Linux, and Mac OS X. It specifies the directory in which the executable program * is located on the machine and can be started without knowing or entering the full path to the file. in the command line. (Or in Windows, the Run dialog box of the Start menu or Win + R) This guide will teach How to Set Environment Variables. in Windows 10.

On Linux and Mac OS X, it generally stores all relevant bin and sbin directories for current users. In Windows, it contains at least the C: \ Windows and C: \ Windows \ system32 directories. This is the reason why you can directly execute any program like notepad.exe or mspaint.exe from the command line or the Run dialog box, but not mozilla.exe. (Mozilla is in C:\Program Files\Mozilla Firefox For more information on environment variables, see this wiki).

How to Set Environment Variables in Windows 10


Type "env" or"environment variables" in start menu.

How to Set Environment Variables in Windows 10

Open Environment Variables Dialogue by clicking the button shown in the screenshot.

How to Set Environment Variables in Windows 10

Create new variables or paths in the System Variables or User Scope

How to Set Environment Variables in Windows 10

You can modify existing variables as well. Make sure you have a backup before playing with these keys.

How to Set Environment Variables in Windows 10

Set Paths and Variables in Windows 10 Settings

  • On the desktop, right-click in the lower left corner of the screen to display the Advanced User task menu.
  • In the Advanced User Task menu, click System.
  • In the Configuration window, go to the corresponding Configuration section and click on the System information link.
  • In the System window, click on the Advanced System Settings link in the left navigation pane.
  • In the System Properties window, click on the Advanced tab and then click on the Environment Variables button at the bottom of the tab.
  • In the Environment Variable window (image below), highlight the Path variable in the System Variable section and click the Edit button. Add or modify Path lines with the path to which the computer must access. Each different directory is separated by a semicolon, as shown below. C:\Program Files; C:\Winnt;C:\Winnt\System32.
Also Read: How to Check Your Computer Temperature

Note: you can edit other environment variables by highlighting them in the variable in the System section and clicking Edit. If you need to create a new environment variable, click on New and enter the name of the variable and its value.

To view and manage the paths on the Windows command line, use the path command.


What are the environmental variables?


If you type calc (the .exe file can be deleted) on the command line in Windows, the Windows calculator starts. (Here you can add support for file extensions other than .exe by modifying %PATHEXT%)

Other variables can indicate which type of device program to use (TERM in Linux / Mac OS X) or, in Windows, where the Windows folder is located (for example,% WINDIR% is C: \ Windows).

Create a new environment variable

On Windows 10, it is absolutely possible to create a new system environment variable, whose value is available for all programs at startup. You can use it when writing scripts or programs installed or distributed on multiple computers, and you need specific reference values for that computer. If the same effects can be achieved using program-specific configuration parameters, it is easier to do so by using environment variables if some programs need to access the same value.
the Windows
Graphics interface
Open the control panel »System» Advanced »Environment variables.

Type control system.cpl in the Run dialog box (Win + R) and then click Environment Variables.
To edit user variables, you can also type

% windir% \ System32 \ rundll32.exe sysdm.cpl, EditEnvironmentVariables
in the Run dialog box.

Right-click on My Computer and click Properties, or simply press Win + Break.

In XP, click on Advanced »Environment variables.
In Vista, click Advanced System Settings »Environment Variables.
There are many other ways to get to the same place, for example, by typing "environment variables" in the Start / Display menu, and so on.

The environment variables in Windows 10 are split into 2 sections, user specific and machine/system specific values. You can see and edit the value here. The current value in the launch is available for all programs.

There is also a quick environment editor, which allows you to manage and modify the environment variables in Windows without having to go too far in the system configuration. Another program of open code for Windows with which you can easily edit the environment of the path is the editor of the path.

Command Line Format

The environment variable in Windows is indicated by the percent sign (%) around the name: %First name%.


echo

To see the value of the environment variable in cmd.exe, type echo %name%.
C:\> echo %USERPROFILE%
C:\> C:\Users\Peter

To create / manage variables, use set varname = value:


set

C:\> set PixRoute = C:\Users\Peter\Images\FunnyPhotos
C: \> set PixRoute = %USERPROFILE%\Pictures


variables

To add / add variables, use set varname = value;% varname%:

C:\> set Panda = C:\WindowsTen
C:\> set Monkey = C: \ WindowsEight;%Panda%

C:\> echo %Panda%
C:\> C:\WindowsEight;C:\WindowsTen

The environment variables arranged in this way are available for (remaining) the process duration of the command prompt in which they are specified, and for the processes that start after the variable is set.

setx

To create / set variables permanently, use setx variable_name "value".
C:\> setx PixRoute "C:\Users\Peter\Images"

[CMD Restart] Even if you restart command prompt, the value of environment variable set with setx will persist forever.

Unlike set, there is no equal sign and the value must be in quotes if they contain spaces. Note that variables can be extended to strings with spaces (for example,% PATH% to C: \ Program Files), so it is best to include quotes around a value that contains variables.

List of Windows environment variables
The following is a list of default environment variables, incorporated in Windows. Here are some examples:% WINDIR%,% SystemRoot%,% USERPROFILE% and% APPDATA%. Like most names in Windows, this is not the case.

Unix Derivatives (FreeBSD, GNU / Linux, OS X)
Environment variables in Linux start with a dollar sign ($) such as $ HOME or $ HOSTNAME. Many known variables and standards are described in uppercase letters to indicate this. Remember that the names of the variables are case-sensitive, which means that $ User and $ USER are completely independent of the shell's point of view.

Unix derivatives define system variables in shell scripts, most of them in the / etc folder, but user-specific values can be assigned to the script variables in the source folder (for example, / Etc / profile, $ HOME / .bash_profile). The .profile file in the home folder is a common place to configure user variables.

Variable parameters


These files are common shell scripts and may contain more than environment variable declarations. To set the environment variables, use export. To see the environment variable that you are currently specifying in the terminal, run approx.

Export commands are a standard way to define variables. The syntax is very intuitive. The results are identical for these two lines, but the first alternative in terms of portability is preferred over the required Bourne pre-POSIX shell.

var = value; export var
export var = value

C shell and its derivatives use a completely different syntax; there, the command is setenv. Contrary to popular belief, OS X is more "Unix" than Linux. In addition to the aforementioned files, $ PATH can be modified in this file: /etc/path contains all the default directories added to the path, such as /bin and /usr/sbin.

Any file in /etc/paths.d: generally used by the installers so that the executable files they provide are available from the shell without affecting the system or the user's specific configuration file. These files contain only one line per line. for example, /Program/Mozilla/Calendar/bin.

Default Windows %PATH% 

The path is based on the program installed on the computer, so there is no "default path". However, the minimum Windows path is usually the following.
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem

Note: remember that when you install a program, the path is updated with the newly installed program path. Therefore, if you have deleted your path after installing another program, these programs may be affected.

How to Change Environment Variables using Command Prompt

Many people usually execute this command "cd/ d C:\". Cool, but executing this command does not change the path permanently, so you must change it when you open the command prompt. Some people also modify the registry to achieve it, but it is easier to play with it.

The last solution I see is to run the command .bat "cd/ d C:\" every time you open the command prompt. This causes additional steps and can create confusion in the future.
The method of this tutorial shows, in my opinion, the most direct and simple way to change the default path.



  • Open the location of the command promptIn the start menu/screen, type "cmd", right click and select "Open file location".
  • Start in Property: Open the property of the command prompt and change the "Start in" property
  • Right-click on the "Command Prompt" icon, select "Properties" and then change the "Start in" property to the desired path. I use "C: \" for example

When you start a command prompt, the default path will be the new path you specified earlier.

You have our undying gratitude for your visit!