Too many folders in the path variable

it is possible to reduce the excessive quantity of paths in the environment variables PATH , just save the whole line out to a notepad, as a backup and remove some and test.

Most of them are there so if a shortcut does not have a full path set for the "Target", If the "Start In" is not set in the shortcut correctly or a launch is done oddly their program and its parts and pieces are always found. It is a Failsafe in most situations. You would still want to test fully any use of any program that you removed its paths.
It is also very usefull to the people who type commands into the CMDprompt, even without a CD, the computer will scan each location, until a program by that name is found and run. Or any other command of the same name :-)

That set of paths WAS (anchient) limited to less than 255(or260) charachters , that changed to 1024 some time long ago, then was patched back in server'03 era to handle 2048 , and supposedly could handle 8096 on some systems , even long ago.

The real limitations discovered today that people run into, is in the CMDprompt which has a limit on the length of the command string, which includes the expanding of the variables and paths.

http://msdn.microsoft.com/en-us/library/windows/desktop/ms682653(v=vs.85).aspx here Microsoft says:

"The maximum size of a user-defined environment variable is 32,767 characters. There is no technical limitation on the size of the environment block. However, there are practical limits depending on the mechanism used to access the block. For example, a batch file cannot set a variable that is longer than the maximum command line length."

At that location ^ they point to the registry location that contains the system paths HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment Must read the rest of it there.

The CMDprompt and batch limitation is 2048 charachters once expanded, and is said to be 4x that for the newer systems (needs citation because people are not seeing that)

Also see http://support.microsoft.com/kb/830473, which discusses the command prompt and batch length for older systems.

To make sure that the entries are correct in there, The wiki has this to say:
http://en.wikipedia.org/wiki/Environment_variable

%PATH% This variable contains a semicolon-delimited (do not put spaces in between) list of directories in which the command interpreter will search for an executable file that matches the given command. Environment variables that represent paths may be nested within the PATH variable but only at one level of indirection. If this subpath environment variable itself contains an environment variable representing a path, PATH will not expand properly in the variable substitution.

Having all the extra paths in there slows certain things down by quite a bit, because it is then forced to look in all those places, before it gives up. Using full paths whenever calling file items will always be faster, even when batching or using the CMDprompt.

Using old DOSlike 8.3 conventions is one way to shrink the size, this Batch https://stackoverflow.com/a/20362922 works well. be sure (again) to backup the orginal string. See also the other possible solutions at that question.

Here is how mine looks, it has been worse.
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\QuickTime\QTSystem\

I would toss out quicktime in a heartbeat, and AMDs programs have put an extended path in there before, tossed it, Adobee had one, none of these mattered for standard GUI shortcut/icon methods. Many things can be removed, then test all functions. If you call up things by typing in the CMD prompt , then removing those paths will not work.


I have several software development related environment variables on my path, all of which are important.

Above solution wouldn't work for me, so I went for directory junctions:

  • Select some of the longest paths in my PATH (Like C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\)
  • Create a small folder to store my junctions: C:\d\
  • Create short junctions for long paths:
mklink /j C:\d\sql "C:\Program Files (x86)\Microsoft SQL
Server\100\Tools\Binn\VSShell\Common7\IDE\"

Doing that on 15 paths reduced my PATH from 2045 to 1285 characters.

It may be a problem when you finally uninstall stuff from your machine as junctions will remain there in the path and you'll have to clean them up manually.