7

What does pushd %~dp0 in .cmd file means? I understand that %~dp0 means it indicates a drive letter. What does pushd indicate?.

D.M
  • 500
  • 6
  • 14
Maddy
  • 91
  • 1
  • 1
  • 5
  • Also see [docs for pushd](https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/pushd) – djvg May 26 '22 at 12:27

1 Answers1

12

Save the current directory on a stack and change to %~dp0 which is the drive-and-path of the "0'th" command-line parameter (which is the command itself) so the destination path to be set is the drive/path of the batch file to be executed.

To return to the original path, you need a popd

Magoo
  • 72,034
  • 7
  • 58
  • 78