Overview
The environment variables are a set of dynamic values used during the running processes. They are introduced in first time in Linux OS but they are used in Windows OSs since 30 and more years old.
The following reading explains how to manage the environment variables either through the User Interface or through the prompt.
Manage the environment variables via User Interface
As a first step you open the "System Properties" windows but there are some differences depending on the operating system version, in detail the change takes place between Windows 7 and Windows 8.
In Windows 8 and Windows 10:- From the Desktop, right-click the very bottom left corner of the screen to get the Power User Task Menu.
- From the Power User Task Menu, click System.
- From the Desktop, right-click the Computer icon and select Properties. If you don't have a Computer icon on your desktop, click the Start button, right-click the Computer option in the Start menu, and select Properties.
Click the Advanced System Settings link in the left column (valid for all operation system versions).
Then click the Environment Variables button near the bottom of that tab. The windows below manages (add, edit and delete) the "User Variables" and the "System Variables".
Example 1
If you want add a new system variable then click on "New...." button under System variables (as shows the picture):After the click, will be showed the following window:
You can put the name and the value of new System Variable. Finally click on "OK" button. The System Variable is created.
Example 2
If
you want edit an user variable, for example "TEMP" then select it and
click on "Edit..." button under User Variables (as shows the picture):
Edit the value and click on "OK" button.
Manage the environment variables via Prompt
The environment variables in Windows are denoted with percent signs (%) surrounding the name:
%VAR%
The echo of a variable you can use the commands as below:
or
To create or edit a variable, you can use:
To append a value to a variable already created:
Environment variables
set in this way are available for (the rest of) the duration of the
Command Prompt process in which they are set, and are available to
processes that are started after the variables were set. After the
closed of Command Prompt the variables are not present. set %VAR%
echo %VAR%
set VAR=value
set APPEND=value2
set VAR=%VAR%;%APPEND%
echo %VAR%
value;value2
Manage permanently the environment variables
The setx command prompt [1] creates or modifies environment variables in
the user or system environment, without requiring programming or
scripting. The Setx command also retrieves the values of registry keys
and writes them to text files.
The setx is available in Windows Vista, Windows Server 2008, Windows Server 2012, Windows 8.
The official syntax [2] is:
setx [/s <Computer> [/u [<Domain>\]<User name> [/p [<Password>]]]] <Variable> <Value> [/m]
setx [/s <Computer> [/u [<Domain>\]<User name> [/p [<Password>]]]] [<Variable>] /k <Path> [/m]
setx [/s <Computer> [/u [<Domain>\]<User name> [/p [<Password>]]]] /f <FileName> {[<Variable>] {/a <X>,<Y> | /r <X>,<Y> "<String>"} [/m] | /x} [/d <Delimiters>]
Some examples:
To set the MYVAR environment variable in the local environment to the value ValueA: set MYVAR valueA
set MYVAR "value A" /m
setx MYPATH %PATH%
setx MYPATH ~PATH~
Internal link
May be of interest to you:
External links
For more detail see the Windows documentation:[1] https://technet.microsoft.com/en-us/library/cc755104(v=ws.11).aspx
[2] https://technet.microsoft.com/en-us/library/cc771080(v=ws.11).aspx
No comments:
Post a Comment