How to recover from PATH being truncated to 1024 characters by SETX

I received an error on Windows 8 after trying to use SETX to add JAVA.exe to the Windows PATH variable:

WARNING: The data being saved is truncated to 1024 characters.

After a reboot, I notice that the PATH is indeed much shorter than before. I've since read that SETX can't handle more than 1024 characters. That would have been good to know in the article which recommended using it.

I am wondering if my system will be unstable now that (presumably) some of the directories no longer appear in the PATH variable. The end of the string is clearly cut off mid-directory (at Pr):

(...) ;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Pr

Is there any way to roll back or anywhere that the previous value of PATH was captured. Man, I can't believe this kind of stuff can still happen in Windows after 29 years.


PATH is saved in the Registry at

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment

If you have system restore points, you can find the relevant key and restore it.