I know this is strange and I have spent almost 3 days searching for the solution online without getting a useful one. So I have decided to come here.
I have recentl
Apparently Rapid Environment Editor will do this for you (from @shital_shah answer), but you can also shorten the paths to their "8dot3" version. You will get a lot of mileage with just these two replacements:
C:\Program Files --> C:\PROGRA~1
C:\Program Files (x86) --> C:\PROGRA~2
If you copy your current path into Notepad first search and replace C:\Program Files (x86)
and then C:\Program Files
.
I found you can do via PowerShell.
[System.Environment]::SetEnvironmentVariable("PATH", "C:\Program Files (x86......etc.....", "Machine")
So I grabbed existing system PATH, pasted into notepad, added my new thing, then pasted into the "C:\Program Files" bit of the above. Path updated. Done.
Late answer but I was looking for something similar and ended up here. I changed all the paths to variables for program files and programdata (this one saves like 1 character though not as important).
For something like nodejs, i changed the normal path of
C:\Program Files\nodejs\
to
%ProgramFiles%\nodejs\
This can be done with "C:\Program Files (x86)\" as well using "%ProgramFiles(x86)%\"
It saved me a few characters but enough that it stopped complaining I feel.
Try modify by regedit
, in my case it works when length more than 3000.
Press Win + R
and enter regedit
to open regedit. Go to Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
, and modify value of Path
to your path. And restart computer, it should works.
I had exactly the same problem, eventually I had to delete one of the existing variable to make the total length < 2047. Then I could add %MAVEN_HOME%\bin
to the path variables.
Workarround. Use Edit Text and edit your PATH in a text Editor