When there are too many entries defined in Windows Path environment variable, you might be faced with this error using the UI when adding a new entry. One solution without having to remove any existing entries is to use the PowerShell snippet below.
For example, to add “C:\Program Files\Java\jdk-14.0.2\bin” to Path :
- Open up Powershell in Administrator mode
- Enter the following:
$newPath = $env:Path + '; C:\Program Files\Java\jdk-14.0.2\bin;' [Environment]::SetEnvironmentVariable("Path", $newPath, "Machine") $env:Path = $newPath
Source: Code Examples