posts - 81, comments - 232, trackbacks - 0

PATH Environment Variable Too Long and Truncated

As I went to append my PATH environment variable on my Windows 7 x64 machine I was surprised by, well perhaps more confused by, not being able to type into the end of the value textbox.

As a reminder, one can edit the PATH variable quickly by

  • Pressing 'Windows Key' + 'Pause Break'
  • 'Advanced system settings' on the left
  • 'Environment Variables' on the lower right corner
  • Selecting 'PATH' under 'System variables'
  • Clicking 'Edit'

Normally I simply click into 'Variable value:' and press the end key to get to the end. Then tack on a semicolon followed by the new path.

This time, however, I could not add more text at the end. I had hit the length limit on the PATH variable. Seriously? Yea…

Apparently you can only key in 2,048 characters. My PATH was already at 2,410, which is oddly larger than 2,048. So perhaps the archaic 'Environment variables' interface is just too strict on the length limits.

First idea

Define PATH using other 'System variables'.

You can modify PATH from the command line with

> SET PATH=%PATH%;C:\My New\Path\

So, perhaps I can define PATH in pieces using other 'System variables'. It turns out you can, and I tried it. I took all of the paths related to development tools and put them into 'DEVPATH'.

I should mention at this point, do the following carefully and at your own risk.

  • Copy the PATH variable value to notepad
  • Keep a copy of the original PATH just in case
  • Move paths in the PATH value to a second line which relate to development (or whatever grouping you like)
  • Be sure that paths are separated by a semicolon
  • Define a new 'System Variable', say 'DEVPATH', and put the extracted paths in the value


  • Append ";%DEVPATH%" to the shortened PATH value
  • Edit PATH and set its value to the new shorter value


  • Click OK twice to apply the changes


Hoping that our PATH variable is now longer and not truncated, I open a new command prompt and echo PATH. Only to find it's truncated in the exact same way. The separation into DEVPATH simply helped to organize the paths… Great, but no fix.

Second idea

Accepting the PATH is limited in length, what to do? Quite simply I had to make it shorter, but I didn't want to break any references.

It turns out a path in PATH includes the directories within the path (sort off). This way we can group and shorten the paths in PATH. I have conveniently separated paths to development applications, those which if broken won't break anything critical, into DEVPATH. Modifying these is then low risk (but again, do at your own risk).

Again editing DEVPATH in notepad, I grouped paths together into 'parent' folders. For example my DEVPATH included

E:\Program Files\Microsoft SQL Server\100\Tools\Binn\;E:\Program Files\Microsoft SQL Server\100\DTS\Binn\;

Which I combined to

E:\Program Files\Microsoft SQL Server;

Doing this enough times my total PATH length was eventually under the limit. Adding my new path to DEVPATH and echoing at the command line confirmed my new path was no longer getting truncated.

Problem solved.


The short answer is to shorten deep paths to a parent path and remove duplicate paths since the PATH references look within the sub directories. Creating a DEVPATH variable was a convenient way to move the 'low risk' paths out of PATH for liberal modification.






Print | posted on Monday, August 27, 2012 5:55 PM |



# ugg saappaat

Uggs boots keep feet toasty even in the freezing cold days and ugg saappaat therefore have become the ugg saappaat suomesta first choices of many customers xiaocaicl15. ugg saappaat boots This kind of footwear looks fashionable ugg saappaat oulu and unique and is available in different uggs saarbrücken styles and colors for your choices. Made with twin-faced sheepskin, these boots feel incredible ugg boots udsalg warm and comfortable. Many celebrities are ugg boots dk also spotted wearing them during the winter season ugg boots tilbud to go through the cold winter. But this conception is ugg boots online quite wrong, as wearing them sensibly especially with jeans and feathery coats really looks cool and exquisite.
11/13/2012 3:14 AM | Zkjykgsng01

# re: PATH Environment Variable Too Long and Truncated

Thanks for the information. Also try Long Path Tool. It helped me with Error 1320 in Win 7. :)
3/8/2013 12:49 PM | GarryBrown

# re: PATH Environment Variable Too Long and Truncated

Not sure how that second option shortening up the path works. I've noticed when I have two paths in the same directory ie( C:\myapps and C:\myapps\otherapps) putting only C:\myapps in the environment path only lets command line see what's in that directory but does not pick up C:\myapps\otherapps so I have to add both of them to the path.

IDK, I'll do some testing.

Thanks for the info and the idea about organizing devpath. I definitely need to do that.

Another option for devtools is to put one devtools directory in the path and in that directory put bat files that call the tools by their full path. I've done that with a few things. It takes some extra work but is similar to how you put executable scripts in usr/bin on a linux system so you don't have to add to the path.
6/7/2013 1:09 PM | Ian

# re: PATH Environment Variable Too Long and Truncated

Could you please let me know, how did you figure out the size of the variable path. Do you have any command for the same.. I am looking for one script , which should display the size of the variable path of environemnt path.

greatly appriciate you help.

7/15/2013 4:48 AM | Ketan

# re: PATH Environment Variable Too Long and Truncated

I think this whole path-issue is very anoying.
How smart are those guys at Microsoft?
First they come up with something like a path-string.
Then they decide to make the max size only 2400 characters.
To edit it they give you an edit box where you can only see 30 of them.
Then they come with products like SQL-server, and after installing it, half of the path-string is used up.
And if only one postion of this string is mixed up, your software does not work anymore.
How fucking stupid are these people?

1/8/2014 9:32 PM | Nicolas Jacobsen

# re: PATH Environment Variable Too Long and Truncated

Nicolas Jacobsen +1
6/6/2014 10:38 AM | Leandro

# re: PATH Environment Variable Too Long and Truncated

Thanks :) tried the second idea and it works.
6/23/2014 3:07 AM | Shady

# re: PATH Environment Variable Too Long and Truncated

if you are using windows vista or higher, you can make a symbolic link to the folder. for example:

mklink /d C:\pf "C:\Program Files"

would make a link so c:\pf would be your program files folder. I shaved off 300 characters from my path by using this trick.
9/11/2014 3:52 AM | Reza

# re: PATH Environment Variable Too Long and Truncated

you are welcome
You can also use Long Path Tool to sort out this problem.

9/12/2014 5:08 PM | andrewop

# re: PATH Environment Variable Too Long and Truncated

Another idea is to split the contents of the long path under the PATH variable in the "User Variables" and the PATH variable in the "System Variables". The actual path is the sum of both the PATHs.
9/18/2014 2:38 AM | egovind

# re: PATH Environment Variable Too Long and Truncated

i really would love to break down my Laptop, the only thing that holding me that i just installed a new IPS display and the colors are amazing,

How the Hell 2048 would be enough, as long as software like SQL Server have a creative naming "c:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\" this is one entry, there are another 10 like it.

and why the hell limiting it anyway .

Microsoft is a mistake
2/27/2015 12:46 PM | Emad AlWari

# re: PATH Environment Variable Too Long and Truncated

I got the same message recently and installed "Long Path Tool" program which solved the problem.
3/27/2015 1:18 PM | andrewpo

# re: PATH Environment Variable Too Long and Truncated

hello friends ,i have same problem ,please try long path tool,its awesome.
6/12/2015 11:55 AM | patrick

# re: PATH Environment Variable Too Long and Truncated

hello friends,i suggest you long path tool, its awesome
6/30/2015 12:37 PM | patrick

# re: PATH Environment Variable Too Long and Truncated

Long Path Tool can fix long path errors. I suggest to everyone.
10/27/2015 8:18 AM | robertvo

# re: PATH Environment Variable Too Long and Truncated

You can also replace some of the Long path names like 'program files (x86)' and such with their short version (i.e. program~2)..

Find the short names by running dir /X pro* (or whatever)
that will save a few characters.

(the symbolic link suggestion is a great one , too. I'll do that for a few as well)
1/14/2016 9:44 AM | Mark

Post Comment

Please add 6 and 7 and type the answer here:

Powered by:
Powered By Subtext Powered By ASP.NET