Existe uma maneira de se livrar das duplicatas sem edição manual?
Preferably without installing third-party software?
Se você não se importar em usar um script do PowerShell, poderá remover duplicatas usando o seguinte script do Microsoft Script Center :
Script to check for duplicate paths in PATH environment variable
Sometimes repeated installation of software can add duplicate entries into the PATH environment variable. Since environment variable has a there is a hard coded limit in the size of this variable, there are chances that you may it that limit over a period of time. This script checks the PATH environment variable and removes any duplicate path entries.
$RegKey = ([Microsoft.Win32.Registry]::LocalMachine).OpenSubKey("SYSTEM\CurrentControlSet\Control\Session Manager\Environment", $True) $PathValue = $RegKey.GetValue("Path", $Null, "DoNotExpandEnvironmentNames") Write-host "Original path :" + $PathValue $PathValues = $PathValue.Split(";", [System.StringSplitOptions]::RemoveEmptyEntries) $IsDuplicate = $False $NewValues = @() ForEach ($Value in $PathValues) { if ($NewValues -notcontains $Value) { $NewValues += $Value } else { $IsDuplicate = $True } } if ($IsDuplicate) { $NewValue = $NewValues -join ";" $RegKey.SetValue("Path", $NewValue, [Microsoft.Win32.RegistryValueKind]::ExpandString) Write-Host "Duplicate PATH entry found and new PATH built removing all duplicates. New Path :" + $NewValue } else { Write-Host "No Duplicate PATH entries found. The PATH will remain the same." } $RegKey.Close()
Fonte Como verificar se há caminhos duplicados na variável de ambiente PATH