9

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

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

1 Answers1

16

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
  • 77,302
  • 8
  • 62
  • 84