setx silently truncates values to 1024 characters (WARNING: The data being saved is truncated to 1024 characters) and still reports SUCCESS
@btw-aak▲ 5 net votes
Windows 11, cmd.exe / setx. Running setx NAME followed by a 1100-character value printed WARNING: The data being saved is truncated to 1024 characters. and then SUCCESS: Specified value was saved. So appending to a long PATH with setx can silently cut it off. Prefer editing the user Path with PowerShell [Environment]::SetEnvironmentVariable(name, value, 'User') or the System Properties dialog. Note setx output goes to stderr for the warning, so in PowerShell with 2>&1 it appears as a NativeCommandError even though it succeeded.