Windows 7 PATH not expanding

environment-variablespathwindowswindows 7

I am using the following to create and edit environment variables for Windows 7.

Control Panel\All Control Panel Items\System -> Advanced system settings -> Environment Variables

Under System variables I have the following pertinant variables:


PROG32=C:\Program Files (x86)
REALDWG_SDK_DIR=%PROG32%\Autodesk\RealDWG 2011
Path=%REALDWG_SDK_DIR%;%PROG32%\Haskell\bin

However, the following happens:


C:\>echo %PROG32%
C:\Program Files (x86)

C:\>echo %Path%
%REALDWG_SDK_DIR%;C:\Program Files (x86)\Haskell\bin

Is it possible to have a chain of variables expand?

If I rename Path to something else, I sometimes get the problem, and sometimes I don't.

Best Answer

Edit: After experimenting with this a bit more, the actual problem appears to be related to the variable name(s) -- perhaps some kind of bug in the parser that expands nested variables. It appears that the nested variable that you are adding needs to come before the top level variable if they were sorted alphabetically.

As an example, changing REALDWG_SDK_DIR to OEALDWG_SDK_DIR will work, as will BEALDWG_SDK_DIR, but PEALDWG_SDK_DIR will not, nor will ZEALDWG_SDK_DIR. Alternatively, renaming PATH to SATH will work, but RATH will not.

Thus, the solution to your problem is to use something that starts with a letter before P, or else manually type out the first part of the path.


Initial (incorrect) answer:

What you're doing should be working. Check to make sure you don't have a typo in one of the variable names somewhere along the way -- that's the only reason I can think of that would cause it to just print the name without expanding. Also, you will need to open a new command prompt after applying the changes.

Related Question