20

I need to enable long paths but my Windows 11 Home edition does not have the group policy editor.

Is there a way to enable this from the command line or install group policy editor on my machine?

Giacomo1968
  • 58,727
A__
  • 477

4 Answers4

21

The proper way to enable long paths in Windows is documented here

It can be implemented by dropping the following into a .reg file and running it if you aren't comfortable editing the registry directly.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem] "LongPathsEnabled"=dword:00000001

The real problem 90% of the time is going to be getting applications to support it and not the file system. Programmers hardcode MAX_PATH (260 chars) into their code and have been doing so for many many years.

It is lazy programming rather than using the windows heap to store the path names.

Some applications are written well enough to get around this but you will find more that don't work than do.

Giacomo1968
  • 58,727
3

Automatically shorten and fix paths with my path_shortener tool

Update: I wrote a path shortening tool in Python to finally solve this problem for me: eRCaGuy_PathShortener. It automagically shortens paths for you and removes illegal chars too.

I'm using it to send zipped up tax files to my tax person from my Linux computer where my paths are too long. My tax person uses Windows.

Usage:

# Help menu
path_shortener -h

shorten all paths in directory test_paths

path_shortener path/to/test_paths

Example of shortened paths:

From path (379 chars): test_paths_shortened/sun_delta_crash_dog_delta_green_iota_sky/brown_forest/whisper_brown_high_wind_wind/fox_phi_lambda_crash_pi_kappa_fox/dog_ocean_sky_nu_chi_nu_mu_sigma_over_shines/beta_nu_over_psi/pi_<>:"\|?*_blue_nu_trees_mu_green_<>:"\|?*_lambda_over/brown_crash_tau_omega_crash_brown/dog_over_brown_aaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbccccccccccccccccccccc/h</a

To path (127 chars): test_paths_shortened/sun_d@7732/brown@BCFE/whisp@F3B2/fox_p@29D5/dog_o@C3E1/beta_@3187/pi___@1BA3/brow@ECD9/dog_@8400/h_#01A4/a

This also automatically generates "namefiles" which are text files that end in _NAME.txt and contain the original path name so you can still easily see what the original path was for all shortened or fixed files and folders.

I invite you to give it a star and try it out. It works awesome.

Original answer:


Enable long paths (> MAX_PATH of 260 chars) in Windows

  1. Press Win and search for powershell. Right-click on "Windows PowerShell" and select "Run as administrator". Type in your username and password to continue.

  2. Run this command in the elevated PowerShell terminal to enable long paths:

    New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force
    

    You'll see this as an output:

    LongPathsEnabled : 1
    PSPath           : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem
    PSParentPath     : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control
    PSChildName      : FileSystem
    PSDrive          : HKLM
    PSProvider       : Microsoft.PowerShell.Core\Registry
    
  3. Done. Some programs will now allow longer paths, so long as the program developers have enabled this feature in their source code and are complying with adding it to their "application manifest" as well. See: https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=powershell

Test it in Git Bash, File Explorer, and VSCode

  1. Install Git for Windows to get access to the Git Bash terminal. See my instructions here: Installing Git For Windows.

  2. Run this in Git Bash

    cd ~
    

    create a 400+ char path

    mkdir -p thisssssssssssssssssssssssssssssss/isssssssssssssssssssssssssssssssss/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/longggggggggggggggggggggggggg/pathhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh/thatttttttttttttttttttttttttttttttttttttttttttttttttttt/shouldddddddddddddddddddddddddddddddddddddddddddd/workkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk/nowwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww

  3. Now manually navigate to there in File Explorer, right-click and go to "New" -> "Text Document". And see if you can create it and open it, edit it, save it, etc.

    Note: I open and edit in in MS VS Code.

  4. It works for me. Done. Awesome!

Possibly still broken?

Update Aug. 2024:

When I manually navigate to the really long path above in File Explorer, right-click and go to "New" -> "Folder" (ie: creating a folder instead of a file), then I see this error in a popup window:

enter image description here

Destination Path Too Long

The file name(s) would be too long for the destination folder. You can shorten the file name and try again, or try a location that has a shorter path.

This seems to indicate to me that my fix above did not work. I'm not sure what to think about this...

Update 4 Oct. 2024: it seems that even if you fix it in the registry, individual programs still are hard-coded to block you based on the old max path length. There is no solution but to wait for these programs to get updated, which could take decades. This includes the Windows File Explorer and unzip tools. So, I wrote this program instead to solve my problem by automatically shortening paths for myself: https://github.com/ElectricRCAircraftGuy/eRCaGuy_PathShortener

The main answer by Señor CMasMas points out this problem too:

The real problem 90% of the time is going to be getting applications to support it and not the file system. Programmers hardcode MAX_PATH (260 chars) into their code and have been doing so for many many years.

It is lazy programming rather than using the windows heap to store the path names.

Some applications are written well enough to get around this but you will find more that don't work than do.

Good luck! :)

References

  1. https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=powershell

Related

  1. My answer: What characters are forbidden in Windows and Linux directory names?
-1

This is because explorer doesn't support long file paths. Not in Windows 10, not in Windows 11.

Although both OS's support long paths.

If you want to work around this, map a drive directly to the folder. That UNC path via mapped drive circumvents the long path allowing you to add files and folders.

Giacomo1968
  • 58,727
-1

This has been a frustrating issue, all the existing answers didn't put it all together, so I spent a lot of time to clarify what's happening and included some tangible evidence.

One can enable LongPathsEnabled with below command and reboot:

reg add "HKLM\SYSTEM\CurrentControlSet\Control\FileSystem" /v LongPathsEnabled /t REG_DWORD /d 1 /f

Once done, there appears to be no change, that's because:

  • Windows Explorer is still limiting you to 260 characters, see 1st error below (still happening as of June 2025)
  • You will be able to create longer paths with the command line though
  • OneDrive behavior: If you create longer folders for a OneDrive directory with the command line to overcome the 260 limit, OneDrive will still stop syncing when you reach 400 characters and will give you an error (2nd error below)

Windows Explorer error even after LongPathsEnabled = 1 (June 2025):

Windows Explorer error (June 2025)

Onedrive error after LongPathsEnabled = 1 and created subfolders with CLI (June 2025):

Onedrive error (June 2025)

Wadih M.
  • 333