posts - 81, comments - 251, 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.

Summary

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 |

Feedback

Gravatar

# ugg saappaat

Uggs boots keep feet toasty even http://www.uggssaappaatsuomi.org/ 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 http://www.uggstovlerdanmark-s.com/ 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.
4
11/13/2012 3:14 AM | Zkjykgsng01
Gravatar

# 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
Gravatar

# 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
Gravatar

# 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.

Thanks
Ketan
7/15/2013 4:48 AM | Ketan
Gravatar

# 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
Gravatar

# re: PATH Environment Variable Too Long and Truncated

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

# re: PATH Environment Variable Too Long and Truncated

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

# 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
Gravatar

# re: PATH Environment Variable Too Long and Truncated

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

.......................
9/12/2014 5:08 PM | andrewop
Gravatar

# 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
Gravatar

# 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
Gravatar

# 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
Gravatar

# 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
Gravatar

# 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
Gravatar

# 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
Gravatar

# 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
Gravatar

# re: PATH Environment Variable Too Long and Truncated

Use Long Path Tool, Long Path Tool can simplify and probably end your problems in unlocking, managing and renaming files that appear to have a long filename.
3/9/2016 9:55 AM | eden
Gravatar

# re: PATH Environment Variable Too Long and Truncated

Long Path Fixer presents you with a simple list of files and folders in the current directory (including "hidden" files and folders). You can drag and drop files or folders onto it and it will navigate directly to path of whatever you dropped.
3/21/2016 7:50 AM | Rogerson
Gravatar

# re: PATH Environment Variable Too Long and Truncated

Long Path Tool help me a lot when i have an issue like file deleting or renaming the file. Also good to use if file name and file extension is too long
6/5/2016 1:51 PM | Roksolana
Gravatar

# re: PATH Environment Variable Too Long and Truncated

Use LONG PATH TOOL, it gives good result in solving the errors in long file like deleting the file, renaming the file, copying the file, etc. Try it......
8/9/2016 1:00 PM | webb123
Gravatar

# Mr

search for related forum posts( where people are looking how to copy, delete, long path files )
and leave there suggestion to try Long Path Tool
8/20/2016 2:58 PM | barryk desteve
Gravatar

# re: PATH Environment Variable Too Long and Truncated

Long path tool is the very good program for error, unlock solution. Try it and solve your problem. I used long path tool and I solve my error, unlock problem solution.
10/4/2016 11:18 AM | aiden carter
Gravatar

# aiden carter

Long path tool is the very good program for error, unlock solution. Try it and solve your problem.
10/4/2016 11:22 AM | aiden carter
Gravatar

# re: PATH Environment Variable Too Long and Truncated

“Long Path Tool” is very helpful for this error !
best solution for your problem.
10/5/2016 1:03 PM | stepan raisa
Gravatar

# Long Path Tool

Long path error!
"Long path tool" is very helpful for this problem. You can solve this problem like copy, delete, long path files by using this tool.
I used to have similar problems too, but after using "long path tool" everything was solved. Try this software and you would be glad you did.
10/6/2016 3:04 PM | Stepan Raisa
Gravatar

# re: PATH Environment Variable Too Long and Truncated

Hi There,

Your post helped in a great way.

thanks
10/19/2016 3:28 AM | Nishant
Gravatar

# Long Path Tool

The Long path tool is the very best program for error, unlock solution.
Try it and solved your problem.
I used the long path tool and I solved my error, unlocks problem solution.
11/10/2016 11:36 AM | aiden carter

Post Comment

Title  
Name  
Email
Url
Comment   
Please add 8 and 6 and type the answer here:

Powered by:
Powered By Subtext Powered By ASP.NET