I'm writing a batch script to edit my PATH variable. Some of my Path consists of variables. Like so: %JAVA_HOME%/bin. In side my batch script I do the following:
FOR %%A IN ("%PATH:;=";"%") DO ECHO %%A | FINDSTR /I /C:%stringToFind% >NUL && SET found=true || SET newPath=!newPath!;%%A
So, the %newPath% variable will contain all the paths I want to keep.
Which is fine, except when I save my newPath to %PATH% using SETX. All my variables are expanded. So, instead of %JAVA_HOME%/bin; I get C:\PROGRA~1\Java\jdk1.8.0_25\bin;
My question is how do I keep my variables in my path as variables. How do I get the paths without expanding the variables. Keep them as: %whatever%. I Googled to no avail. Any help greatly appreciated.