Monday, January 16, 2012

Path Over 2048 Chars Kills Windir Environment Variable

All of a sudden my cmd prompts in Windows 7 had no PATH environment variable.  And when I tried to change my path (Right Click on My Computer -> Properties -> Advanced Settings) I got a terrible error message about %windir%\systempropertiesadvanced.exe not being found.

Bottom line, if your PATH environment variable is more than 2048 characters it (and WINDIR) stop being visible in many contexts.

I fixed it by manually running c:\windows\system32\systempropertiesadvanced.exe and deleting one entry from my PATH to put me under 2048 chars.  New cmd windows work just fine.

Interesting that you can't use the GUI to increase path length above 2048; only badly behaved installers are allowed to do that?

Props to for pointing me in the right direction.  I haven't found any other acknowledgement that this issue exists.


Anonymous said...

Thanks for the fix. This has been driving me crazy! My environment variables would disappear when ever I would log into the system with Remote Desktop. This would cause the icons for apps in the system32 folder to be broken. Then they would magically come back a few days later.

Anonymous said...

Your blog post is a life saver. Or maybe a hair saver as I was starting to pull my hair out trying to figure out what was wrong. Thanks! Is this data somewhere in the MS documentation on MSDN?

Anna Pinnolis said...

Bless you! What a FWP nightmare this has been.