97

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?!

3
  • 2
    I've recently had the same problem on my 64-bit Vista box. With no obvious cause, if I open a new command prompt, then the path variable is set to the part of the path defined in "User variables". The "System variables" part of the path is missing. Some, but not all system variables are undefined. The registry looks OK, and everything looks OK in the System Properties dialog (using "c:\windows\system32\systempropertiesadvanced.exe"). After reboot, the system functions normally. Problem reoccurs every few days. A full virus scan found nothing.
    – Lee
    Jan 10, 2012 at 14:35
  • I had the same problem. I found a few different things that triggered it (running certain programs, running installers, etc.) but no reason those would cause it (they work fine on other machines or in a VM.) Eventually I had other problems compounding the need to reinstall which fixed everything. Jan 17, 2012 at 2:27
  • 4
    my path was too long. I removed duplicates, removed useless entries and problem is gone.
    – Pavel P
    Feb 13, 2012 at 0:48

4 Answers 4

126

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

8
  • 2
    I just fixed the problem by restarting the computer... That's really a stupid limit of Windows!
    – Edwin Yip
    Oct 22, 2013 at 12:38
  • 3
    Just ran into this problem. What a joke. Thanks May 2, 2014 at 17:37
  • 3
    As others mentioned, after fixing your PATH, just restart explorer.exe in the task manager if you don't want to reboot. Please make sure you DO NOT launch task manager by right clicking the task bar! Doing that will initialize task manager with the jacked up path (and hence your new explorer.exe process). Launch it by doing ctrl + shift + escape
    – C. Tewalt
    Jun 8, 2015 at 15:06
  • 1
    Thank you for this. I was fighting this for the last month or so when a Sony product increased my path by around 200 chars. Oct 15, 2015 at 17:36
  • 1
    What I did in addition to what Raven proposed: replace common base dirs like c:\program files (86) in the path variable with another variables like for example PRGX86 pointing to the program files dir. That way you can save some additional characters.
    – ovm
    Apr 1, 2016 at 10:45
23

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.

4
  • 2
    ok that's pretty genius
    – kenwarner
    Sep 13, 2014 at 20:51
  • 1
    Very clever, but apps that dynamically add PATH entries will likely be operating on the fully expanded path and will still go nuts. But at least the pain will be scoped to that process.
    – Raven
    Oct 27, 2014 at 17:05
  • Thank you for this great Idea, but it unfortunatly did not work under Win7: the variable "extpath" -- or in your case "pathextended" -- was not parsed..... Dec 2, 2015 at 18:43
  • 2
    This solution didn't work for me in Win 7. The contents of the 2 variables were concatenated, but any characters after the 2048th(?) were truncated from the resulting combined PATH variable. So I had to remove entries from PATH in the end, as per @Raven, to get my icons and %windir%, etc to come back.
    – snark
    Jan 6, 2017 at 14:07
12

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.

enter image description here

2.

enter image description here

3.

enter image description here

EDIT: update for newer versions of Windows.

Task Manager now does it in one step:

enter image description here

6
  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post - you can always comment on your own posts, and once you have sufficient reputation you will be able to comment on any post.
    – Michael K
    Jul 11, 2014 at 9:28
  • With respect, I disagree. The question is, Windows 7's PATH and environment variables are corrupted. My response provides a way to remove that corruption. This is a relevant answer both in its own right, and in conjunction with other fixes after which a reboot would otherwise be needed.
    – Reg Edit
    Jul 11, 2014 at 9:36
  • I would suggest to edit Ravens answer and add your part to it. Most people will only read the accepted answer and if I understand correctly, your answer is mostly an addition to that.
    – Michael K
    Jul 11, 2014 at 9:41
  • Ah, I see. No, it's relevant to any solution being tried. I've edited my answer to make that clearer.
    – Reg Edit
    Jul 11, 2014 at 10:21
  • 1
    this was probably more worthwhile as a comment than an answer. That rather than restart he should end task explorer.exe and restart explorer.exe. Your answer addresses part of his problem - this part "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." But notice that since he has a path problem after a restart, this wouldn't fix his problem anymore than he has by restarting.
    – barlop
    Jul 11, 2014 at 18:32
3

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .