Last active
July 15, 2026 02:31
-
-
Save CypherpunkSamurai/a5a7c28326124e6f49e5f8cd3eb8c405 to your computer and use it in GitHub Desktop.
Remove Path Limit Cause Retarded Microsoft Employees Know More Than You About Your Computer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # DEDUP + LONG PATHS — run in elevated PowerShell | |
| $path = [Environment]::GetEnvironmentVariable('Path', 'Machine'); $seen = @{}; $deduped = ($path -split ';' | ForEach-Object { $_.Trim() } | Where-Object { $_ -ne '' -and -not $seen.ContainsKey($_.ToLower()) } | ForEach-Object { $seen[$_.ToLower()] = $true; $_ }) -join ';'; [Environment]::SetEnvironmentVariable('Path', $deduped, 'Machine'); $reg = 'HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem'; Set-ItemProperty -Path $reg -Name 'LongPathsEnabled' -Value 1 -Type DWord; $gpo = 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\FileSystem'; if (-not (Test-Path $gpo)) { New-Item -Path $gpo -Force | Out-Null }; Set-ItemProperty -Path $gpo -Name 'LongPathsEnabled' -Value 1 -Type DWord; Write-Host "PATH deduped ($($path.Split(';').Count - $seen.Count) removed). Long paths enabled. REBOOT." -ForegroundColor Green |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 1. Define the action (What the task does) | |
| $Action = New-ScheduledTaskAction -Execute "reg.exe" -Argument 'add "HKLM\SYSTEM\CurrentControlSet\Control\FileSystem" /v LongPathsEnabled /t REG_DWORD /d 1 /f' | |
| # 2. Define the trigger (When the task runs - At Startup) | |
| $Trigger = New-ScheduledTaskTrigger -AtStartup | |
| # 3. Define the principal (Run as SYSTEM with highest privileges) | |
| $Principal = New-ScheduledTaskPrincipal -UserId "NT AUTHORITY\SYSTEM" -LogonType Service -RunLevel Highest | |
| # 4. Define settings (Ensure it runs even on battery power) | |
| $Settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries | |
| # 5. Create and register the permanent task | |
| Register-ScheduledTask -TaskName "ForceLongPathsOnBoot" -Action $Action -Trigger $Trigger -Principal $Principal -Settings $Settings -Description "Permanently forces Windows Long Paths to stay enabled after updates." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment