I think the best way is the next (with powershell)With this way also you avoid the litmit of 1024 character.
You can see the code on: https://gist.github.com/drazul/b92f780689bd89a0d2a7
#------------ Add path to system variable -------------------------------------$path2add = ';C:\path;'$systemPath = [Environment]::GetEnvironmentVariable('Path', 'machine');If (!$systemPath.contains($path2add)) { $systemPath += $path2add $systemPath = $systemPath -join ';' [Environment]::SetEnvironmentVariable('Path', $systemPath, 'Machine'); write-host "Added to path!" write-host $systemPath}#------------ Delete path from system variable --------------------------------$path2delete = 'C:\path;'$systemPath = [Environment]::GetEnvironmentVariable('Path', 'machine');$systemPath = $systemPath.replace($path2delete, '')$systemPath = $systemPath -join ';'[Environment]::SetEnvironmentVariable('Path', $systemPath, 'Machine');write-host "Deleted from path!"write-host $systemPath#------------ Clean system variable -------------------------------------------$systemPath = [Environment]::GetEnvironmentVariable('Path', 'machine');while ($systemPath.contains(';;')) { $systemPath = $systemPath.replace(';;', ';')}[Environment]::SetEnvironmentVariable('Path', $systemPath, 'Machine');write-host "Cleaned path!"write-host $systemPath