How to return to last directory with cmd.exe? [duplicate]

Possible Duplicate:
Can windows command line support Linux “cd -”?

Under Linux, I can use cd - to return to the last directory. How can I do that on Windows?


Solution 1:

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

Solution 2:

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