Environment variable is too large on Windows 10

When the PATH environment variable gets overloaded with too many values it reaches a point where you cannot add values any more. Trying the following should solve your problem.

Solution 1:

  1. Create a new system environment variable, say 'NEWPATH'
  2. Assign the bin directory location to 'NEWPATH'
  3. Now append '; %NEWPATH%' to the PATH environment variable

If this still doesn't work then try to copy some part of the PATH environment variable already existing values to the 'NEWPATH' and then append the 'NEWPATH'.

Solution 2:

Check the value of the PATH environment variable if you can group and shorten the paths. For example,

C:\Program Files\Microsoft SQL Server\102\Tools\Binn;C:\Program Files\Microsoft SQL Server\102\DTS\Bin;

can be combined to

C:\Program Files\Microsoft SQL Server;

In this way, you can build more space into your fixed length PATH variable and finally adjust your bin directory location into PATH.


There are a few ways to clean up your path variable. The easiest is to use Rapid Environment Editor. This free utility will,

  1. Remove the duplicate paths (right click → Cleanup Paths)
  2. Remove non-existent folders (shown in red which you need to manually delete)
  3. Replace long paths with short paths (right click → long to short path).

I do the above steps in order and use the third step only for the longest paths until the Path variable size is under control again.

If you want to go more advanced, here's a little C# tool that you can modify to whatever other logic you want to implement.


Another solution, or more a workaround to bypass the PATH environment variable length limit, is to manage your path (add, remove or update) using a PowerShell script;

  1. Capture the current PATH variable by clicking "Edit Text" (see above screenshot) and copy it to your clipboard and save it in a text file as a backup too to avoid bad surprises. This is not mandatory, but will allow you to recover should something go wrong.

  2. Now that it is backed up, add the following to a new PowerShell (.ps1) file (amending the first line below with the folder path(s) you want to add (the part after the + sign):

$newPath = $env:Path + '; C:\Users\....\FirstFolderToAddToPath; C:\Users\....\SecondFolderToAddToPath;'

[Environment]::SetEnvironmentVariable("Path", $newPath, "Machine")

$env:Path = $newPath

This is how I managed to get my (long) PATH variable back after playing with the Windows 10 UI, being caught by the length limitation and losing most of my path.


Try to modify by RegEdit. In my case it works when length is more than 3000.

Press Win + R and enter regedit to open RegEdit. Go to Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment, and modify the value of Path to your path. And restart the computer, and it should work.


In addition to the answer of Swapnil, note that you can modify the maximum length of the Path environment variable - which is otherwise limited to 2048 characters (while a single path has an historical limit of 206 characters).

In Windows 10, you achieve this by setting the LongPathsEnabled registry key to 1, which can be found here:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem

To access the registry editor: Windows key + R, type Regedit.

Source: Windows 10 “Enable NTFS long paths policy” option missing

Also take a look at this Super User answer: An answer to Windows 10 “Enable NTFS long paths policy” option missing

Note that the error "Environment variable is too large" is related to the whole variable, not the single path currently being added (to answer the "inaccurate advice" comment below).

Additional note: app compatibility

The text in the registry key/group policy related to LongPathsEnabled reads:

Enabling NTFS long paths will allow manifested win32 applications and Windows Store applications to access paths beyond the normal 260 char limit per node. Enabling this setting will cause the long paths to be accessible within the process.`

The caveat here is the term manifested. In general applications need to declare capabilities explicitly in a manifest file; most win32 applications since the days of Windows Vista are manifested. To use long paths, the app manifest needs a longPathAware element:

<application xmlns="urn:schemas-microsoft-com:asm.v3">
    <windowsSettings xmlns:ws2="http://schemas.microsoft.com/SMI/2016/WindowsSettings">
        <ws2:longPathAware>true</ws2:longPathAware>
    </windowsSettings>
</application>

More info here.

Some users complained that LongPathsEnabled is not yet supported by Windows Explorer and other apps, although in general working alternatives can be found. For example, in this forum post an user states that

The only explorer alternative that does support long paths and long file names is total commander. It also allows to edit file names and open/process the files IF the accepting application also uses the extended API function.
Notepad seems to. MKVtoolnix too. Also, very surprisingly, MPC-HC, even though it hasnt been in development for years. Not surprisingly, sucky VLC does not (seriously?) and neither does the lovely PotPlayer.

There is also an interesting SuperUser discussion on this. In particular, this answer describes two feasible alternatives to use long paths: using Cygwin (a *nix emulation layer) or splitting the long path using NTFS Junction Points (essentially a link, like a symbolic link).