Windows 7 64-bit Enterprise Edition
When running a .cmd or .bat script and using %~f0 or %~dp0 to resolve the batch script name if the batch script name has spaces (ex: "my script.cmd") and you chdir within the script then further references to %~dp0 will incorrectly resolve to the new cwd instead of the correct batch script location.
This does not happen if the script name has no spaces in it.
Example script below:
@REM When this script is named "test.cmd" (no spaces) it works as expected for the value of %~f0
@REM When this script is named "test with spaces.cmd" it does not work
echo "Stage 1: dp0 == %~dp0"
echo "Stage 2: dp0 == %~dp0"
echo Should have gotten value %STAGE1%