⚡ PowerShell 5.1+

Enable Win32 Long Paths

Lifts the legacy 260-character MAX_PATH limit for apps that opt in (requires admin). Requires an elevated (Administrator) prompt.

By WindowsScripting.com · 741 B
Set-EnableLongPaths.ps1
<#
.SYNOPSIS
    Enable Win32 Long Paths.

.DESCRIPTION
    Lifts the legacy 260-character MAX_PATH limit for apps that opt in (requires admin). Requires an elevated (Administrator) prompt.

    Sets HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem \ LongPathsEnabled to 1.

.EXAMPLE
    .\Set-EnableLongPaths.ps1
#>

[CmdletBinding()]
param()

$regPath = 'HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem'

if (-not (Test-Path $regPath)) {
    New-Item -Path $regPath -Force | Out-Null
}

New-ItemProperty -Path $regPath -Name 'LongPathsEnabled' -Value 1 -PropertyType DWord -Force | Out-Null

Write-Host "Enable Win32 Long Paths applied. Sign out and back in (or restart explorer.exe) for it to fully take effect." -ForegroundColor Green