Note - this question is based on behavior observed on Windows 7. I believe the behavior applies to all other versions from Vista onward. Based on MC ND\'s answer, and Fo
According to this command line reference there are read-only environment variables, where __CD__ is included.
From that page:
Undocumented Dynamic variables (read only)
%__CD__% The current directory, terminated with a trailing backslash.
%=C:% The current directory of the C: drive.
%=D:% The current directory of the D: drive if drive D: has been accessed in the current CMD session.
%=ExitCode% The hex value of the last return code set by EXIT /B
%=ExitCodeAscii% The ASCII value of the last return code set by EXIT /B if greater than 32.