If you're not beholden to setx
, you can use an alternate command line tool like pathed. There's a more comprehensive list of alternative PATH editors at https://superuser.com/questions/297947/is-there-a-convenient-way-to-edit-path-in-windows-7/655712#655712
You can also edit the registry value directly, which is what setx
does. More in this answer.
It's weird that your %PATH%
is getting truncated at 1024 characters. I thought setx
didn't have that problem. Though you should probably clean up the invalid path entries.