For some reason there are certain Environment Variables that won't expand when used in the "PATH" variable in the System Variables.  For example, %SystemRoot% works just fine while %WinDir% doesn't. %ProgramFiles% and %ProgramFiles(x86)% doesn't work either.   Obviously I know that I could just use the full path rather than a variable but that's not the point.  Any ideas?  Here is a screenshot/example:
122717
What is difference between %Windir% and %Systemroot% in Windows Path Location? Both of them show "Windows" folder location.
102281
I tried to persist the environment variables for ORACLE in RedHat using /etc/environment.  It cleared my PATH variable; no command was recognized afterwards.  Why does it happen, since just executing the same commands in the shell just works fine?!   The contents of my /etc/environment:  ORACLE_HOME=/usr/lib/oracle/12.1/client64 PATH=$ORACLE_HOME/bin:$PATH LD_LIBRARY_PATH=$ORACLE_HOME/lib
11530
I want to set my path (and some other environment variables) based on a certain directory, so I have the following file in my home directory  export MY_DIR="/path/to/dir" export PATH=$MY_DIR/bin:$PATH export MY_OTHER_VAR="$MY_DIR/folder"   I source that in my ~/.zshrc with the following line: [[ -e ~/my_file.sh ]] &amp;&amp; emulate sh -c ' source ~/my_file.sh  However, when I log in, $MY_DIR/bin is not in my path. If I echo $PATH, I get %F{51}~%f where $MY_DIR/bin should be. However, both MY_DIR and MY_OTHER_VAR were set correctly.  Have I done something wrong, or is this some weird bug in zsh (it seems to work as expected with bash)?  Edit  I have used both source and ~ elsewhere in my zshrc without issue. However, I tried moving the file to /etc/zsh/my_file.sh and sourcing it from etc/zsh/zprofile. I also tried using . rather than source, but even with those changes, I still see the same %F{51}~%f in my path variable. Actually, I've noticed that I see whatever my current directory is in the PATH variable, so for example, if I navigate to /etc/zsh/ and echo $PATH, I see %F{51}/etc/zsh%f.  Full code to reproduce:  /etc/zsh/zprofile:  [[ -e /etc/zsh/my_file.sh ]] &amp;&amp; emulate sh -c ' . /etc/zsh/my_file.sh'   /etc/zsh/my_file.sh:  export MY_DIR="/home/matt/code" export PATH="$MY_DIR/bin:$PATH" export MY_PYTHON="$MY_DIR/python"   EDIT 2  So I am using a custom prompt which prints my current path in cyan. If I disable that prompt, my PATH variable gets set properly. In the script for the prompt, I use a variable that I call path (lowercase). Apparently, while bash doesn't confuse it with PATH, zsh does. Thanks to all for the help.
63360
I'm running Ubuntu 11.04. I use the terminal to start a bash session, and I want to add an environment variable:  $r@hajt:~$ env THEVAR=/example   But it's not working. It shows all the variables with THEVAR being the last one, but another call to env does not show THEVAR anymore- env | grep THEVAR returns nothing.  Similarly, scripts with export (export THEVAR=/example) or other variable assignments (THEVAR=/example) don't add the environment variable.  I know I'm doing something wrong, I know it should be something simple, but I just can't find what.  UPDATE: The real meaning of my question was this one:   (Anyway I'll choose the most voted answer and leave the edited title -that wasn't what I was asking)  env runs a program in a modified environment, then dismisses all the changes.
39983
I recently discovered /etc/environment, which seems a more standard way to setup simple environment variables than scripts, but I was wondering if there was a way to back-reference environment variables in the /etc/environment file.  That is, I have this:  JAVA_HOME="/tools/java" GRAILS_HOME="/tools/grails" GROOVY_HOME="/tools/groovy" GRADLE_HOME="/tools/gradle" PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"   If I try to add $JAVA_HOME/bin to the PATH definition, however, I get $JAVA_HOME/bin, and not the interpolated variable. To remedy this, I'm creating environment.sh in profile.d to add the /bin entries to the path, but this seems sloppy and disorganized.  Is there a way to backreference the environment variables in /etc/environment?
28646
I've read in a couple of places that the PATH is set in /etc/profile or the .profile file that's in the home dir.  Are these the only places that the path is set in? I want a better understanding of it.  In the /etc/profile file, as the following comment says "system-wide .profile file for the Bourne shell". Does that mean that profile files are the main configuration files for bash?  In that file I don't see the PATH var being set at all. In the .profile file in the home directory there's this line:  PATH="$HOME/bin:$PATH"   That's resetting PATH by the looks because it's concatenating the already set $PATH string with $HOME/bin: right? But if etc/profile and ~/.profile are the only files setting PATH where is $PATH coming from in that line of code if it's not defined in /etc/profile?  Can someone experienced please give a broad and detailed explanation of the PATH variable? Thanks!
7238
I use a command line tools under windows 10. The path to the tool is set in the system PATH variable so that it can be started from the command line.  Whenever a new version of the tool comes out, I store it to a new directory and update the system PATH to point to the new location. Restart the command window and everything is fine, the new version of the tool is used.  After a ahutdown and start however, the PATH reverts back to the old value and the old version of the tool gets used. Opening the envoronment variable editor and clicking OK, without making any changes, solves the problem ... until the next shutdown. I have searched the whole registry, the old PATH value is nowhere found. It must be stored somewhere else.  After some time, (I guess after a windows update gets installed, but I am not sure about this) the problem goes away and the new PATH value is remembered.  In previous windows versions this worked without problems, I see this behaviour only after upgrade to Windows 10.  How can this be fixed? Is there some way to make the effective PATH permanent?
111951
The idea would be to use it as... a pipe in a command. For instance: say there's some kind of long path which has to be retyped again and again, followed by a pipe and a second program, i.e.  "directory1/directory2/direcotry3/file.dat | less -I "   I'd like that part to be stored in a variable, so it could be used like this:  r="directory1/directory2/direcotry3 \| less -I -p " $ cat path1/path2/$r &lt;searchterm&gt;   Instead, I get  cat: invalid option -- I Try `cat --help' for more information.   ... meaning the pipe clearly didn't work.
64931
I have a user, say user1, which has modifications to its .bash_profile, one of them changing the PATH, e.g.: export PATH=/some/place:$PATH. This change works fine if I log on as user1 or do a su - user1.  But if I try to run a command via su as root, e.g.:  su -c test.sh oracle   (test contains echo $PATH)  It doesn't seem to have the modified PATH (or root's PATH, for that matter). I've also tried copying .bash_profile to .profile, to no avail.   Why is this happening?
96718
I'd like a way to add things to $PATH, system-wide or for an individual user, without potentially adding the same path multiple times.  One reason to want to do this is so that additions can be made in .bashrc, which does not require a login, and is also more useful on systems which use (e.g.) lightdm, which never calls .profile.  I am aware of questions dealing with  from $PATH, but I do not want to remove duplicates.  I would like a way to add paths only if they are not already present.
51902
In Windows 7, when I start the Command prompt, is there any command to display the contents of an environment variable (such as the JAVA_HOME or PATH variables)?  I have tried with echo $PATH, echo PATH and $PATH but none of these work.
57130
How I can use a variable name in file path ?  ssl_certificate /home/ec2-user/.certificados/$server_name.crt; ssl_certificate_key /home/ec2-user/.certificados/$server_name.key;
67994
I accidentally deleted the Path environment variable by creating a new one with Path name. How can I restore my old Path environment variable?
43318
Update: The link below does not have a complete answer. Having to set the path or variable in two places (one for GUI and one for shell) is lame.  Not Duplicate of:     Coming from a Windows background where it's very easy to set and modify environment variables (just go to System Properties > Advanced > Environment Variables), it does not seem to be that straight forward on Mac OS 10.5. Most references say I should update /etc/profile or ~/.profile. Are those the equivalent of System Variables and User Variables? For example, where should I set my JAVA_HOME variable?    EDIT:  I want to be able to access the variable from the terminal as well as an app like Eclipse. Also, I hope I don't have to restart/logout to make this take effect.
35087
In scripts, first line should specify the path to interpreter. But on different servers Linux, Unix, or BSD this path could be different.  What is more preferable?  #!/usr/bin/env bash    or  #!/bin/bash
94277
In first.bat, I use  var5=C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\x86_amd64\ CALL scripts\vc64.bat %var5%   And in scripts\vc64.bat, I use  SET var6=%1vcvarsx86_amd64.bat CALL %var6%   But I get : 'C:\Programvcvarsx86_amd64.bat' is not internal or external command..... error.  If the path assigned to var5 has no space, then it is fine.  I tried several combination of quotations and %1vcvarsx86_amd64.bat, but no change.  How do I make it works with path with spaces?    To be more precise, suppose it is C:\a b c\  In first.bat:       SET var6=C:\a b c\  =====&gt;  '"C:\avcvarsx86_amd64.bat"' is not.....`      SET var6="C:\a b c\" ====&gt;   There should not be a b      SET var6=C:\a\ b\ c\ ====&gt;    Can't find the specified path      SET var6=C:\a b c\ + Using "%var6" ====&gt; There should not be a b     Update: Here is an example. Change a b to ab works.  call.bat in C:\  @ECHO OFF  SET var5=C:\a b\ CALL C:\1.bat "%var5%"  pause   1.bat in C:\  @ECHO OFF  SET var6=%~1Test.bat CALL %var6%  RMDIR /S C:\NoWorry   Test.bat in C:\a b Test.bat in C:\ab  @ECHO OFF  RMDIR /S C:\ThereIsNoSuchFolder
60999
Whatever I try to run, I get the error:   The command could not be located because '/usr/bin' is not included in the PATH environment variable.   I had some modification in my .bashrc file but then removed the two additional lines afterwards. However somehow the PATH variable seems to have been destroyed.