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

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.


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


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


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

Windows 7 / Fedora 12

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


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

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:

(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)


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


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

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:


But in path it doesn't fully decompress:

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

Windows 7 / Fedora 12


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


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

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

 Limits to environment variable nesting?

Thread Tools

Similar help and support threads for2: Limits to environment variable nesting?
Thread Forum
Are USB Cable Length Limits hard limits? Hardware & Devices
Set permanent variable in cmd General Discussion
Nesting Virtual Operating Systems Virtualization
Robocopy mass nesting bug General Discussion
repeated variable bsods BSOD Help and Support

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 04:52 PM.
Twitter Facebook Google+

Windows 7 Forums

Seven Forums Android App Seven Forums IOS App

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33