Bill Meyer 337 Posted May 27 I would have thought that it should be easy to find documentation on the maximum Windows PATH length. I have found many articles, none of them comprehensive. The only specification which seems to be straightforward is the MAX_PATH = 260 limit on the file path. What I am looking for, however, is whether the full PATH variable has a specified limit. Share this post Link to post
Attila Kovacs 629 Posted May 27 (edited) 2048 Just for the record. Nothing to do with your question. 1 hour ago, Bill Meyer said: The only specification which seems to be straightforward is the MAX_PATH = 260 limit on the file path. For file I/O, the "\\?\" prefix to a path string tells the Windows APIs to disable all string parsing and to send the string that follows it straight to the file system. For example, if the file system supports large paths and file names, you can exceed the MAX_PATH limits that are otherwise enforced by the Windows APIs. For more information about the normal maximum path limitation, see the previous section Maximum Path Length Limitation. Because it turns off automatic expansion of the path string, the "\\?\" prefix also allows the use of ".." and "." in the path names, which can be useful if you are attempting to perform operations on a file with these otherwise reserved relative path specifiers as part of the fully qualified path. Many but not all file I/O APIs support "\\?\"; you should look at the reference topic for each API to be sure. Note that Unicode APIs should be used to make sure the "\\?\" prefix allows you to exceed the MAX_PATH. Edited May 27 by Attila Kovacs Share this post Link to post
Anders Melander 1783 Posted May 27 Similarly unrelated, the MAX_PATH limitation can also be circumvented with the manifest: https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests#longPathAware 2 Share this post Link to post
Attila Kovacs 629 Posted May 27 That works only if [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem] "LongPathsEnabled"=dword:00000001 is set 1 Share this post Link to post
Bill Meyer 337 Posted May 28 This morning, a colleague offered this: https://devblogs.microsoft.com/oldnewthing/20100203-00/?p=15083 It is likely to be the best explanation to be found. Share this post Link to post
Remy Lebeau 1394 Posted May 28 In theory, up to 32K: What is the maximum length of an environment variable? 20 hours ago, Attila Kovacs said: 2048 The actual PATH environment variable itself is not limited to that length, but in practice, various tools that set the path, and various APIs that use the path, are limited. https://superuser.com/questions/1385854/how-do-i-bypass-restrictions-on-the-length-of-the-path-variable https://www.askwoody.com/forums/topic/what-is-the-real-path-length-limit-in-windows-10/ https://learn.microsoft.com/en-US/troubleshoot/windows-client/shell-experience/command-line-string-limitation That last one theorizes that the PATH could be as much as 8K, not 2K. So, the limitation is not so much on the variable itself, but on how it's used. Share this post Link to post
limelect 48 Posted June 11 See my free application for long names I hope it will answer your question https://limelect.com/downloads/find-long-names/ Share this post Link to post
corneliusdavid 214 Posted June 11 On 5/28/2024 at 8:00 AM, Remy Lebeau said: https://superuser.com/questions/1385854/how-do-i-bypass-restrictions-on-the-length-of-the-path-variable Using tricks like this to is how I've gotten several versions of Delphi installed on one box (along with everything else I use regularly). The PATH setting on my machine only takes 1,876 characters but when fully expanded, it's 6,327 characters long! Every time I install another version of Delphi, I ignore the "PATH is close to the limit" warning, then go edit it later, creating, for example, D23 to replace "C:\Program Files (x86)\Embarcadero\Studio\23.0". Share this post Link to post
Sherlock 663 Posted June 11 @Uwe Raabe Has written a nifty tool to circumvent this: https://www.uweraabe.de/Blog/2014/09/09/the-garbled-path-variable/ 1 Share this post Link to post
corneliusdavid 214 Posted June 11 1 hour ago, Sherlock said: Uwe Raabe Has written a nifty tool to circumvent this That looks pretty cool. I'm a little nervous about running a program that messes with such an important part of Windows operations but it looks like it would work well. Share this post Link to post
Uwe Raabe 2057 Posted June 11 Current version is available on GitHub: https://github.com/UweRaabe/CompressPath 3 Share this post Link to post