I have some sort of a problem with the PATH system variable. Since I use a lot of cmd apps and scripts I've added a lot to it. But the string's length is not the issue. I've worked around this limitation.

Advanced System Properties is the only application which I've noticed to initialize the PATH variable properly after an edit. If I edit registry manually, apps don't use the updated version of the PATH. So I have to use it or keep loggin on and off.

However, lately, after setting some values of PATH in that app, it always ends up being (null), even if it's the same string. Once I press OK, it goes dark. Registry entries are still there. I have to log-off or restart for the PATH to get populated with whatever is in its registry entry.

I've even trimmed it down to %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem Still, PATH=(null) and %windir% is dead.

Leave it alone, it works.

Edit it, nope. Not until I restart.

So, any ideas?... about why advanced system properties is behaving like this when updating the system variables. I believe this is the issue, since it's an initializing app and since on a clean restart everything works.

  • %windir% is its own WinDir environment variable, not part of PATH, so if it's going blank as well you've got larger problems than just the PATH variable. Anything odd in the Event logs? Have you done an SFC /scannow yet? Feb 20, 2014 at 16:03
  • I hate /scannow... messes up sometimes more than it fixes. Did a /verifyonly and it did not find any integrity violations. I did mess around some more with those entries. One of them was called ESET_OPTIONS. Googled it, nothing. It wasn't doing anything besides using up exactly 2079 space chars. Might it be that the whole amount of VARIABLES summed up should not surpass a certain length? Before that var I've put 0SYS as %SystemRoot% and this one shows up. In fact, all vars before ESET_OPTIONS show up. I always thought it's a per variable limitation.
    – JasonXA
    Feb 20, 2014 at 19:57
  • The environment variables should be automatically trimmed of trailing whitespace before being added. So if it had 2000+ empty characters, it sounds like it was corrupted (garbage that appears as spaces because it's actually unprintable characters), and corrupting anything in memory after the 2079th character (ie: the variables after it). Did completely removing that ESET_OPTIONS variable fix things? Feb 20, 2014 at 20:37
  • Not completely. At least now, some expand, others, lower in the list don't. My PATH is now at 68 chars with declared vars and 530 with vars expanded (what gets printed). I've added %windir% last and it didn't expand. 530 isn't near as close to the 2047 limit per variable (goo.gl/lfdfBQ), nor does this: "Win XP: The maximum size of the environment block for the process is 32,767 characters. Starting with Windows Vista [...] there is no technical limitation on the size of the environment block." prove correct (goo.gl/DaKgWA). My block's apparently limited.
    – JasonXA
    Feb 20, 2014 at 20:55
  • Gradually, I'm getting to the problem... almost there and it's not a length limitation.
    – JasonXA
    Feb 20, 2014 at 21:07

3 Answers 3


After some tries, I managed to come up with some basic Environment variable rules when working with command line tools and PATH.

1st. A) Length: No Variable should be longer than 2047. If there are variables longer than 2047, variables after them won't expand, won't show up and Path will become null, PATH=(null).

It's very unlikely to arrive here but as it happens, I was in this situation and this was the main issue, however, this limitation is tricky, because it comes in effect only after editing the Environment variables in the editor (Advanced System Settings / SystemPropertiesAdvanced.exe). It will not have any negative effect if the variables are left unedited after booting up, but, if child explorer are executed for browsing in separate process, the command consoles opened from those explorer windows will be affected.

1st. B) Which Length? It doesn't matter. If a variable is used in Command console it is limited either way to 2047 chars of value, expanded or declared.


x = %variable001%;%variable002%;%variable003%;...;%variable146%;%variable147%

Won't work.
Up to 146, it will because x won't be longer than 2047.
But 147 will kill it. Length of %variable???%; x 147 = 2058.


x001 = C:\Program Files
x002 = C:\Program Files
x003 = C:\Program Files
x120 = C:\Program Files
x121 = C:\Program Files

z = %x001%;%x002%;%x003%;...;%x120%;%x121%;

Will work but will show only up to x120 and part of x121.
Length of C:\Program Files; x 120 = 2040 + C:\Prog of x121

2nd. Place: Expandable variables don't expand recursively. In registry they are of type REG_EXPAND_SZ, in Environment variables editor they are set if the % character is typed in. If there are such variables declared, this needs to be done so that they are initialized before PATH. Normal variables don't have this issue. They can be declared after PATH and their values will still show.

a = C:\Windows
b (exp) = %SystemRoot%
c (exp) = %a%;%b%;%x%;%y%
x = C:\Windows
y (exp) = %SystemRoot%
z (exp) = %a%;%b%;%x%;%y%

echo %c% will output C:\Windows;C:\Windows;C:\Windows;%y%
                          a          b          x      y
echo %y% will output C:\Windows
echo %z% will output C:\Windows;C:\Windows;C:\Windows;C:\Windows
                          a          b          x          y

Variable y was not expanded inside c because it was declared after c, but was expanded in c's clone, z.

So, to keep PATH alive and well, there has to be no lengthy variable before it and it can contain expandable variables as long as they are declared before Path in an alphabetical hierarchy (from a to o). All while keeping a final value length below 2048.

  • Here's a little explanation on how and why the length can be an issue, including the quirky 2047-character limit when updating through the Advanced System Settings GUI. If you use another method to update the registry value that stores the environment variable, the theoretical maximum limit of PATH is actually much larger, around 32760 characters. Aug 28, 2014 at 15:48

I had the same experience! Your "PATH" is simply too big!

PATH cannot be longer than "a certain number of characters", can't remember how many.

Anyway, this limit is enforced in that control panel window that lets you edit it.

IF you open the registry and just add text to it, you can make it bigger; but doing this you're just overflowing it.

An interesting side effect is that %windir% loses its value too.

Of course, in the registry they're both filled with bytes, but windows cannot read them.

So the solution is:

  1. open PATH editor in the control panel
  2. delete a character
  3. try to add a, say, an 'a' (hitting the 'a' key)
  4. If you cannot add the 'a', repeat from step 2. Otherwise, congratulations: you found the PATH limit. You cannot make it bigger than that

I fixed this issue by resetting the PATH variable using the good old DOS style path.

Long folder name - c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC

Equivalent short name - c:\PROGRA~2\MICROS~1.0\VC

Thanks to Timbo for the solution for %I in (.) do echo %~sI to get the DOS path. POST

Hope this might help resolve the issue.

You must log in to answer this question.

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