Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How are Windows Environment variables evaluated?

If I have a System and User environment variable with the same name, how are they processed? Are they concatenated? Does the user variable override the system variable? Taking that into account, if I need to add something to the Path variable, where is it more convenient to add it?

like image 818
mjsr Avatar asked Feb 26 '11 11:02

mjsr


People also ask

How do Windows environment variables work?

An environment variable is a dynamic "object" on a computer, containing an editable value, which may be used by one or more software programs in Windows. Environment variables help programs know what directory to install files in, where to store temporary files, and where to find user profile settings.

How do I find the value of an environment variable in Windows?

On the Windows taskbar, right-click the Windows icon and select System. In the Settings window, under Related Settings, click Advanced system settings. On the Advanced tab, click Environment Variables.

How do I test environment variables?

On WindowsIn the command window that opens, enter echo %VARIABLE%. Replace VARIABLE with the name of the environment variable you set earlier. For example, to check if MARI_CACHE is set, enter echo %MARI_CACHE%. If the variable is set, its value is displayed in the command window.

Does user variable override system variable in Windows?

A regular user environment variable overrides completely a system one with the same name if both exist, but only for the specific user it is specified for. However, the user path variables is treated differently. It is appended to the system path variable when evaluating, rather than completely replacing it.


2 Answers

I think this article should answer you question: Environment variables in Windows NT

User environment variables

User environment variables can be viewed from Control Panel as well. The user may add, delete or modify the environment variables in the User Environment Variables for User field. These variables take precedence over system environment variables. The user path is appended to the system path.

like image 183
splash Avatar answered Oct 08 '22 00:10

splash


Everything splash says in their answer is correct. To be absolutely clear, there is a difference between how the user path environment variable is evaluated, and the other user environment variables are evaluated. A regular user environment variable overrides completely a system one with the same name if both exist, but only for the specific user it is specified for. However, the user path variables is treated differently. It is appended to the system path variable when evaluating, rather than completely replacing it. I believe splash states that, but they do it so concisely I think it needs spelling out.

like image 36
Simon Avatar answered Oct 07 '22 23:10

Simon