Windows 7’s PATH and environment variables are corrupted

I have no clue, but lately I’ve been having this problem. After running my workstation suddenly something destroys PATH and lots of stuff stops working. Initially, my path had MANY directories listed (I use Windows 7 as a development box) and after some time, I only had 3-4 directories listed in my path left.

I can’t even open the System Properties dialog where I can see environment variables (because it uses shell variables to start it and it doesn’t work). In short, I reboot every time.

Any ideas what might cause that problem? I didn’t run anything new/unusual lately. Only VmWare (but I’ve been using it in the past and didn’t have that problem back then).

I just checked, even %WINDIR% is not defined. WTF?!

Solution:

From my blog

 

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:windowssystem32systempropertiesadvanced.exe and deleting one  entry from my PATH to put me under 2048 chars.  New cmd windows work  just fine.

Update: This similar question claims 2047 is the max, and elaborates on expansion rules