Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Limits to environment variable nesting?

21 Aug 2010   #1
trycatch

Windows 7 / Fedora 12
 
 
Limits to environment variable nesting?

So, is there a limit to how deeply environment variables can be nested in Windows? I do a lot of development work and I'm trying to set up my development environment vars, and a lot of them nest off each other, ie.

FOO=C:\path\to\foo
FOO_BAR=%FOO%\bar
BAR_ETC=%BAR%\etc

I'm having some trouble getting Windows to expand all of them. Eventually when I look at 'set' I get an output like:

FOO=C:\path\to\foo
FOO_BAR=C:\path\to\foo\bar
BAR_ETC=%BAR%\etc


Is there some limit to how deeply it'll expand envvars? Is there a way to coax it into looking more deeply? A registry entry perhaps?

Thanks all!


My System SpecsSystem Spec
22 Aug 2010   #2
dranfu

 

Have you enabled delayed expansion?
My System SpecsSystem Spec
22 Aug 2010   #3
trycatch

Windows 7 / Fedora 12
 
 

Quote:
Have you enabled delayed expansion?
Thanks for your help

I'd never heard of that before. Just Google'd around and looked at it, I tried (from cmd) "setlocal enabledelayedexpansion" and echoing a nested library path and it doesn't look like it worked..

Perhaps I'm using it wrong.. everywhere I see it used, it's being used in scripts and such, though I'm not sure how I can make this work for me here. I'm setting these envvars in the actual system properties so they're globally accessible when I'm doing my development work... is there a way to do delayed expansion on these types of envvars?
My System SpecsSystem Spec
22 Aug 2010   #4
dranfu

 

Try Catch,

Can you post the path names (whether they use variables or not) as you have them set in the Environment Variables dialog in windows. If you need to, you can change the names, for privacy.

Next, can you post a copy of the SET command below that. Again, just change names, like %USERNAME%, for privacy.
My System SpecsSystem Spec
23 Aug 2010   #5
trycatch

Windows 7 / Fedora 12
 
 

I'm not currently at my PC in question but I can give it to you mostly from memory. I've had this issue before and it's usually when I get about five deep that it starts to refuse expanding any further.

It'll be something like:
DEV_HOME=C:\dev
THIRD_PARTY=%DEV_HOME%\thirdparty
OSG=%THIRD_PARTY%\OpenSceneGraph
OSG_ROOT=%OSG%\OpenSceneGraph-2.8.3
OSG_INCLUDE_PATH=%OSG_ROOT%\include
GLEW=%THIRD_PARTY%\GLEW
GLEW_ROOT=%GLEW%\glew-1.5.5
GLEW_INCLUDE_PATH=%GLEW_ROOT%\include


(The reason for the [foo]_ROOT is for keeping multiple versions of dev packages around, I can just toggle [foo]_ROOT to point to a different one...)

When I run set from cmd, I'll get (from memory, I'll post the actual contents later when I get back to my PC, but I'm 99% sure this is right)

DEV_HOME=C:\dev
THIRD_PARTY=C:\dev\thirdparty
OSG=C:\dev\thirdparty\OpenSceneGraph
OSG_ROOT=C:\dev\thirdparty\OpenSceneGraph\OpenSceneGraph-2.8.3
OSG_INCLUDE_PATH=%OSG_ROOT%\include
GLEW=C:\dev\thirdparty\GLEW
GLEW_ROOT=C:\dev\thirdparty\glew-1.5.5
GLEW_INCLUDE_PATH=%GLEW_ROOT%\include

It gets as far as OSG_ROOT and GLEW_ROOT and then OSG_INCLUDE_PATH and GLEW_INCLUDE_PATH refuse to expand. Can't cd to it or anything. I'll double check that this is exactly where it breaks later. Needless to say this is frustrating because that's THE depth layer I need it to get to. D:
My System SpecsSystem Spec
23 Aug 2010   #6
dranfu

 

I've nested a number of paths, many "variables" deep, but honestly I've really only done it in batch files, and they are tempprary directories. But the concepts are really just the same. However, it would be more helpful, as im sure you know, if I can see the actual data, and not something posted from memory

I'll go home and try some nesting in the env~ var~ dialog and see if I can reproduce the error. I'm personally interested in the outcome myself.
My System SpecsSystem Spec
23 Aug 2010   #7
trycatch

Windows 7 / Fedora 12
 
 

I was in the middle of copying for set and explaining where it went wrong when I realized... everything is expanded now..

Confusion level = high. I haven't rebooted lately, and I know I opened a new cmd after trying the delayed expansion... I need to poke around with this a bit. I don't suppose you were able to force any errors?

EDIT: WAIT, no... GLEW_BIN_PATH fully expands:

GLEW=C:\dev\third-party\GLEW
GLEW_1_5_5=C:\dev\third-party\GLEW\glew-1.5.5
GLEW_BIN_PATH=C:\dev\third-party\GLEW\glew-1.5.5\bin
GLEW_INCLUDE_PATH=C:\dev\third-party\GLEW\glew-1.5.5\include
GLEW_LIB_PATH=C:\dev\third-party\GLEW\glew-1.5.5\lib
GLEW_ROOT=C:\dev\third-party\GLEW\glew-1.5.5
THIRD_PARTY_ROOT=C:\dev\third-party

But in path it doesn't fully decompress:
%THIRD_PARTY_ROOT%\GLEW\glew-1.5.5\bin;

I've got it listed in Path as just GLEW_BIN_PATH%; tacked onto the end of path.

................... and now GLEW isn't expanding and OSG still is....

Confusion level going critical...
My System SpecsSystem Spec
23 Aug 2010   #8
trycatch

Windows 7 / Fedora 12
 
 

AH HA!

Okay I seem to have tracked it down. What was causing one set of dev envvars to expand and the other not had to do with I had some user specific envvars set for OSG and forgot about it, which was causing a few conflicts. Here's what I've tracked down.

It's not nesting, it really is a lack of delayed expansion, but I can't seem to get around it. Here's what's going on...

GLEW/OSG_LIB, _INCLUDE, and _BIN, all depend on GLEW/OSG_ROOT, which is expanded AFTER all of them. So now what I'm getting is _LIB, _INCLUDE, and _BIN are all just having unexpanded variables in them. I've tried enabling delayed expansion but that's not getting me anywhere.. any thoughts (other than renaming _ROOT to something alphabetically first?)
My System SpecsSystem Spec
23 Aug 2010   #9
dranfu

 

I think I may see some errors in logic here, but give me a few minutes. Also, just an FYI, you would have gotten a lot more responses than one if you posted this to Stack Overflow , a Coders Q&A forum, full of nothing but coders. Or even Server Fault , a Sys Admins forum, full of nothing but sys admins.

Seven Forums is great, but it really has a different focus. IYKWIM
My System SpecsSystem Spec
23 Aug 2010   #10
trycatch

Windows 7 / Fedora 12
 
 

I feel like if I had gone to SO or a coders forum I would have gotten a lot of "WUT IS THIS GO TO A WINDOWS FORUM" responses. lol I can say from experience from living in a few coder IRC channels if you ask something vaguely off topic it can get testy quickly. :/

I restarted and now everything expands EXCEPT I have OSG_BIN_PATH and GLEW_BIN_PATH in my Path variable and they DON'T expand... this is all very odd...
My System SpecsSystem Spec
Reply

 Limits to environment variable nesting?




Thread Tools





Similar help and support threads
Thread Forum
Are USB Cable Length Limits hard limits?
I'm trying to get a longer cable for my digital SLR camera, so I can live preview / shoot from the computer. The camera has about a 3 foot cable with a special USB end. I was just going to order a 15 foot usb extension cable, but this would put me at a total of about 18 feet. Will this extra 2...
Hardware & Devices
Set permanent variable in cmd
I am trying to find a way to set a variable in the cmd that is "permanent". What I mean is that I could set the variable %message% to "hello", and I could close the cmd, open it up a week later and if I typed this: echo %message% This would be the result hello Using the normal SET command...
General Discussion
Nesting Virtual Operating Systems
I have a 64 bit version of windows 7 that has the Window XP mode bonus virtual guest OS. So my question is should i nest a virtual OS inside windows XP mode if i want to install MS-Dos a 16 bit operating system or can windows 7 host a 16 bit guest OS
Virtualization
i7 950 OC limits
hey, first what would be a safe clock or an i5 (not asking for like voltage, just a general ghz range) and to support it using a gigabyte x58 usb3 mobo plus, a cheap and effective cooler?
Hardware & Devices
Robocopy mass nesting bug
Didn't know where else to put this so I hope this is good. Twice now I have experienced a issue with robocopy where while copying a user folder it mass nests the Application Data folder within Local. It replicates this to both \User\AppData\Local and \User\Local Settings. Weird thing is Local...
General Discussion

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 02:34.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App