Windows Server 2016 was finally released last week, meaning we can finally lift the idiotic 260 characters limitation for NTFS paths. In this post I'll show you how to configure the "Enable Win32 long paths" setting for the NTFS file system, by a Group Policy Object (a GPO), and "LongPathsEnabled" in the Windows registry. This is still required for Windows Server 2022 and Windows Server 2019.

Maximum Path Length Limitation (MAX_PATH) in Windows Server

Microsoft writes about the Maximum Path Length Limitation on MSDN, and they write:

Maximum Path Length Limitation

In the Windows API (with some exceptions discussed in the following paragraphs), the maximum length for a path is MAX_PATH, which is defined as 260 characters. A local path is structured in the following order: drive letter, colon, backslash, name components separated by backslashes, and a terminating null character. For example, the maximum path on drive D is "D:\some 256-character path string<NUL>" where "<NUL>" represents the invisible terminating null character for the current system codepage. (The characters < > are used here for visual clarity and cannot be part of a valid path string.)

Microsoft Developer Network: Naming Files, Paths, and Namespaces

In the past, this 260 characters limitation caused errors and discomfort. Especially in the web hosting branche where you sometimes have to be able to save long file names. This resulted in (too) long paths and thus errors.

For example, have a look at this WordPress #36776 Theme update error Trac ticket. Which was a duplicate of #33053 download_url() includes query string in temporary filenames.

Fortunately, this limitation can now be unset and removed. Per default the limitation still exists though, so we need to set up a Local Group Policy. Or a Group Policy (GPO) in my case, since my server is in an Active Directory domain network.

In this post you'll learn how to set up a GPO to enable NTFS long paths in Windows Server 2016 and Windows Server 2022/2019 using the LongPathsEnabled registry value.

Enabling "Long Paths" doesn't magically remove the 260 character limit, it enables longer paths in certain situations. Adam Fowler has a bit more information about this is. Or are you wondering how to increase the configured maxUrlLength value in Windows Server & IIS? This'll fix an IIS error "The length of the URL for this request exceeds the configured maxUrlLength value".

But first things first.

You need to be able to set up this GPO using administrative templates (.admx) for Windows Server 2016. Because, in my situation, my Active Directory server is Windows Server 2012 R2 and doesn't provide GPO settings for 2016.

Download Administrative Templates (.admx) for Windows 10 and Windows Server 2016

If you are, as me, on Windows Server 2012 R2 (at the time of this writing), you need administrative templates (.admx files) for Windows Server 2016 to configure 2016 specific Group Policy Objects. The same goes for Windows Server 2022 and 2019.

These few steps help you setting them up in your environment.

Download and install administrative templates for Windows Server 2016 in your Windows Server 2012 R2 Active Directory

Folow these steps:

  1. Download Windows 10 and Windows Server 2016 specific administrative templates - or .admx files.
  2. Install the downloaded .msi file Windows 10 and Windows Server 2016 ADMX.msi on a supported system: Windows 10 , Windows 7, Windows 8.1, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012, Windows Server 2012 R2. You also need user rights to run the Group Policy Management Editor (gpme.msc), or the Group Policy Object Editor (gpedit.msc). But that's for later use.
  3. The administrative templates are installed in C:\Program Files (x86)\Microsoft Group Policy\Windows 10 and Windows Server 2016, or whatever directory you provided during the installation. Copy over the entire folder PolicyDefinitions to your Primary Domain Controller's SYSVOL\domain\Policies directory.
  4. Verify you've copied the folder, and not just the files. The full path is: SYSVOL\domain\Policies\PolicyDefinitions. This is explained in Microsoft's Technet article Managing Group Policy ADMX Files Step-by-Step Guide.

That's it, you now have Group Policy Objects available for Windows Server 2016. Let's enable Win32 long paths support now.

Configure "Enable Win32 long paths" Group Policy

Learn how to set up WMI filters for Group Policy.

Now that you have your Windows Server 2016 Group Policy Objects available, it's time to setup a GPO to enable NTFS long path support. Create the GPO in your preferred location, but be sure to target it on Windows Server 2016 only.

Please note that the GPO is called Enable Win32 long paths, not NTFS.

Enabling Win32 long paths will allow manifested win32 applications and Windows Store applications to access paths beyond the normal 260 character limit per node on file systems that support it. Enabling this setting will cause the long paths to be accessible within the process.

Start your Group Policy Management console and click through to the location where you want to add the GPO. Create a new GPO: Create a GPO in this domain, and Link it here..., and provide your GPO with a relevant name.

In the Settings tab, right click and choose Edit.... Now under Computer Configuration in the Group Policy Management Editor, click through to Policies > Administrative Templates > System > Filesystem. Configure and enable the Setting Enable Win32 long paths.

This screen configures the GPO
Configures "Enable Win32 long paths" GPO
this screen is a settings overview for the created GPO
GPO Enable Win32 long paths Settings overview

This is all you have to do to create the Group Policy for long Win32 paths. All that is left is to run gpupdate in an elevated cmd.exe command prompt.

Verify LongPathsEnabled registry value

If needed, you can use the following cmd.exe or PowerShell commands to verify the LongPathsEnabled registry value is set correctly:

C:\>reg query HKLM\System\CurrentControlSet\Control\FileSystem /v LongPathsEnabled

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\FileSystem
LongPathsEnabled REG_DWORD 0x1
PS C:\> (Get-ItemProperty "HKLM:System\CurrentControlSet\Control\FileSystem").LongPathsEnabled
1

Don't forget about your Windows Server 2022 and Windows Server 2019 servers, they still require this LongPathsEnabled registy value.

Use PowerShell to configure "Enable Win32 long paths"

If your servers are not in an Active Directory network and you want to enable the "Win32 long paths" (or LongPathsEnabled registry value) you can use PowerShell for the job. Here is a small PowerShell script that adds the registry value if the script is run on an supported Windows Server version.

#
# Add LongPathsEnabled registry value using PowerShell
#
function Test-RegistryValue {
param (
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[string]$Path,
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[string]$Value,
[switch]$ShowValue
)

try {
$Values = Get-ItemProperty -Path $Path | select-object -ExpandProperty $Value -ErrorAction Stop
if ($ShowValue) {
$Values
}
else {
$true
}
}

catch {
$false
}
}

# Windows Server 2016 build is 10.0.14393
[version]"10.0.14393"
[version] $winver = $(Get-CimInstance -Namespace root\cimv2 -Query "SELECT Version FROM Win32_OperatingSystem").Version

if($winver -ge [version]"10.0.14393") {
if ($(Test-RegistryValue "HKLM:System\CurrentControlSet\Control\FileSystem" LongPathsEnabled) -eq $false) {
New-ItemProperty -Path "HKLM:System\CurrentControlSet\Control\FileSystem" -Name LongPathsEnabled -PropertyType DWORD -Value 1 -Force
}
}

This script contains a function that tries to look up if the requested registry path / value already exists. If it returns false, New-ItemProperty is executed to add LongPathsEnabled with value 1 to the Windows. A reboot afterwards is required.

Enable Win32 long paths in Windows 11 and Windows 10 (Bonus!)

If your client computer running Windows 11 or Windows 10 is not in an Active Directory and/or does not have the above mentioned GPO active, you can enable it yourself in a local security policy (LSP). You do need administrator privileges to follow the next steps:

  1. As an administrator, start gpedit.msc for example in an elevated PowerShell terminal venster or through Start (Select the as administrator option). Press enter and Group Policy Editor opens.
  2. Go to Local Computer Policy -> Computer Configuration -> Administrative Templates -> System -> Filesystem, then enable the Enable Win32 long paths option.
  3. Restart your computer.
Start gpedit.msc as Administrator
Enabling Win32 long paths will allow manifested win32 applications and Windows Store applications to access paths beyond the normal 260 character limit. Enabling this setting will cause the long path to be accessible within the process.
Enabling Win32 long paths will allow manifested win32 applications and Windows Store applications to access paths beyond the normal 260 character limit. Enabling this setting will cause the long path to be accessible within the process.

Of course you can add the registry value manually as well. Want to silently import .reg file in your Windows registry?

Donate a cup of coffee
Donate a cup of coffee

Thank you very much! <3 ❤️

19 Comments

  1. Alex

    I did it. Did both GPO and registry dword 1 and a reboot after.
    Nthing changed. Win Serv 2019 stda

  2. Morty

    I’d like to know how to make the workstations on a domain, so they cannot make a file/path name longer than 100 characters.
    File/Path names get re-iterated and wordy.
    I’ve never seen a manila file folder with a 200 character name, and computers shouldn’t either.

    • Thank you for your message Morty. Unfortunately that’s beyond the scope of this article. But perhaps one of the visitors reading this blog post and your comment has an answer.

  3. Peter Wein

    Hi Jan,

    once again me, I followed long time ago your link, and managed to update regedit and the local computer configuration like described. The related option is set to true or 1, and system was rebooted. Today I did a gpupdate.exe as administrator from terminal.

    Till now, we are facing issues on our jenkins nodes, that path names are not allowed to be bigger than 260 characters. If workspace is corrupted for example by metadata of an eclipse project, it is very painful getting rid of these long path constructs. I have to manually rename every folder to a single character to finally delete the whole stuff.

    This can’t be real on Windows Server 2016!! I am going nuts on this annoying issue.

    Did I oversee something or do I have to manually install anything via Server dashboard. Or is this setting only applying to applications which have a proper application manifest, which I as an end user can’t guarantee obviously??

    Thanks in advance
    Peter

    • I’m sorry Peter, I’m afraid I can’t help you any further.

      One thing you could check is whether or not you can create paths longer than MAX_PATH (260 chars). For example with PowerShell (let’s see how this formats as a comment):

      PS C:\Users\janreilink> $longdir = './12characters/12characters/12characters/12characters/12characters/12characters/12characters/12characters/12characters/12characters/12characters/12characters/12characters/12characters/12characters/12characters/12characters/12characters/12characters/12characters/12characters/12characters/'
      PS C:\Users\janreilink> New-Item -Type Directory $longdir
      PS C:\Users\janreilink> cd $longdir
      PS C:\Users\janreilink .. 12characters> (Get-Location).path.Length
      305
      PS C:\Users\janreilink .. 12characters> New-Item -Type File testfile.txt
      PS C:\Users\janreilink .. 12characters> (Get-ChildItem .\testfile.txt).FullName.Length
      318

  4. Peter Wein

    Thanks Jan!

  5. Peter Wein

    Hi Jan! Thanks for the explanation. I am not a system administrator, just forced to somehow “maintain” a windows 2016 server, where my static code analysis with Polyspace Bugfinder as a jenkins slave runs.

    I have these issues with:
    15:57:38 Error: File or path name(s) length must not exceed 260 characters.

    during my analysises.

    I tried following your explanation but stumbled at two points:
    – domain controller : I guess this is a server that can be used to get all servers aligned, alright?
    Anyway, I skipped this part, because I did found the related Directory SYSVOL (=C:\??)/domain/…. and just installed the tool
    – enabled the related option in the group policy tool and updated as administrator, like you told. I again skipped “Create the GPO in your preferred location, but be sure to target it on Windows Server 2016 only”

    Do I have to reboot afterwards (I won’t hope so)?

    I did not reboot, because important analysis’s are running. But as far as I can see, the issue remains stable long pathes are not allowed.

    Can you give me a special (secret ;-)) hint? Thanks in advance, Peter

    • Hi Peter, thank you for your comment.

      If it’s for just one server there is no need in setting up group policies. Enable the ‘Enable NTFS long paths’ policy in your Local Computer Policy, it’s explained here on Stack Overflow’s Super User: https://superuser.com/a/1119980.

      Enabling ‘NTFS long paths’ doesn’t make longer than 260 char paths accessible to you, but to win32 applications. From the Policy help text:

      Enabling Win32 long paths will allow manifested win32 applications and Windows Store applications to access paths beyond the normal 260 character limit per node on file systems that support it. Enabling this setting will cause the long paths to be accessible within the process.

      You can also create a 32-bit DWORD value named LongPathsEnabled directly in your registry, and set it to 1. The path is HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem

      In both cases you do need to reboot your server unfortunately.

  6. George

    Is there a way to set this using the registry and not through UI?

    • Hi George,
      Excuse my late reply.

      You can set this directly in the registry:

      Create a 32-bit DWORD value named LongPathsEnabled
      Set it to 1
      The path is HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem

  7. Viktor

    Where I can change this parameter for Windows 2012R2?

    • Hi Viktor,
      Unfortunately, you can’t. NTFS long paths is for Windows Server 2016 only.

  8. What do you mean by, “be sure to target it on Windows Server 2016 only.” Does this not work on Windows Server 2012?

    • Hi Susan, thank you for your comments.

      Yes, you can install and add the Group Policy ADMX Files to your Windows Server 2012 Domain Controller. But you can only use this GPO setting on -deploy to- Windows Server 2016, it is a 2016 only setting.

  9. Susan E Bercaw

    What do you mean by, “be sure to target it on Windows Server 2016 only”. I thought that you were saying that this would work on a Windows Server 2012 domain controller.

  10. Anders

    I have done this, buts its not working.
    Tryed on windows server 2016, local gpo and domaine gpo. Same result.
    I have go all rettings in regedit and all settings is enabled.
    However its still says error long paths

    • Hi Anders, thank you for your comment. Unfortunate to hear it didn’t work for you to enable Win32 long paths.

      I wouldn’t set up both a local group policy and domain group policy (GPO). They might (will) conflict with each other. If you are in a Active Directory Domain, then only set up your GPO. And you can always check with gpresult if your GPO is loaded correctly. And have you tried rebooting after enabling the GPO?

Comments are closed