How to return to last directory with cmd.exe?

You can use the pushd and popd commands.

  • pushd <dir> will change directory from location a to location b
  • popd will change directory back to directory a

Example:

pushd %TEMP%     // go to user's temp dir, and remember
pushd \Windows   // go to windows dir, and remember
popd             // go back one dir, in this case the temp dir
popd             // go back one more dir, in this where you were before temp

Cmd.exe is an emulation layer for the old MS-DOS, commands are the same :

  1. One step backward = cd..
  2. All Backward = cd /

For the others look at some Ms-Dos table around the web