Enable NTFS long paths (Windows Server 2016) (Group Policy – Powershell)


To totally unlock this section you need to Log-in


Login

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 where 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.)

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

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.

You need to be able to set up this GPO using Administrative Templates (.admx) for Windows Server 2016. Because, in our situation, our, for example, 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 in this situation, as our example, on Windows Server 2012 R2, you need Administrative Templates (.admx files) for Windows Server 2016 to configure 2016 specific Group Policy Objects.

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

Folow these steps:

  • Download Windows 10 and Windows Server 2016 specific administrative templates – or .admx files.
  • 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.
  • 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.
  • Verify you’ve copied the folder, and not just the files. The full path is: SYSVOL\domain\Policies\PolicyDefinitions.

That’s it, you now have Group Policy Objects available for Windows Server 2016.

Configure Enable Win32 long paths 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. And do note that the GPO is called Enable Win32 long paths, not NTFS.

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.

Enable NTFS long paths (Windows Server 2016) (Group Policy - Powershell)

Enable NTFS long paths (Windows Server 2016) (Group Policy - Powershell)

Enable NTFS long paths (Windows Server 2016) (Group Policy - Powershell)

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.

Using the Registry Editor

You can enable the policy in the Windows Registry directly as well.

  • Tap on the Windows-key, type regedit.exe and hit Enter.
  • Confirm the UAC prompt.
  • Navigate to the following key: HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy Objects\{48981759-12F2-42A6-A048-028B3973495F}Machine\System\CurrentControlSet\Policies
  • Check if the key LongPathsEnabled exists.
  • If it does not exist, right-click on Policies and select New > Dword (32-bit) Value from the menu.
  • Name it LongPathsEnabled.
  • Set its value to 1 to enable the feature.