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 1:
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:\windows\system32\systempropertiesadvanced.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
Solution 2:
The 2048 character limitation is real. What I did is split the path in two separate variables and include the second variable in the PATH variable:
PATH=C:\;%PATHEXTENDED%
PATHEXTENDED=E:\
Like that I did not have to delete any PATH directories but got the PATH variable under 2048 characters.
Solution 3:
A workaround fix for anyone trying to resolve this problem, either due to excessive path
or for any other reason: just restart Explorer. The new shell picks up a new environment. This fixes the corruption for the time being, without having to reboot, even if you haven't yet been able to identify and permanently resolve the underlying cause.
1.
2.
3.
EDIT: update for newer versions of Windows.
Task Manager now does it in one step:
Solution 4:
you should get a program to monitor the registry keys
user variables
HKCU\Environment
and
machine variables
HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
you might catch the moment they get destroyed and narrow it down.
also, time how long it takes..after bootup. if you can at least know when it'll happen it'll help in narrowing things down.
try safe mode too. incase it's process related, and check event viewer.