The POPD command in Windows Command Prompt is used to restore the previous value of the current directory saved by the PUSHD command. This is particularly useful in scripts and batch files where you need to change the working directory temporarily and then revert back to the original directory.


The syntax of the POPD command is straightforward with no parameters:



POPD does not have any options or flags. Its sole function is to pop the directory stored by PUSHD from the stack and change the current directory to that location.


  1. Basic Usage
    First, use PUSHD to save the current directory and change to another directory:

    PUSHD C:\Windows

    After executing some commands in C:\Windows, use POPD to return to the original directory:

  2. Using with Scripts
    In a batch script, navigating to a directory to perform tasks and then returning:

    @echo off
    REM Perform operations in the temp directory
    echo Back to the original directory

Common Issues

  • Stack Underflow: If POPD is used without a corresponding PUSHD, it results in an error because there’s no directory stored in the stack to return to. Ensure that every POPD in your scripts follows a PUSHD.
  • Network Drives: When used with network paths, POPD and PUSHD might encounter issues if network connections are lost or permissions change between the push and pop operations.


POPD can be integrated seamlessly with other CMD commands to perform complex directory navigation tasks in scripts. For example, combining with DIR to list files in a temporary directory and then returning:

@echo off

This script lists all files in the C:\Temp directory before returning to the original directory.

  • PUSHD: Saves the current directory and changes to a specified directory.
  • DIR: Displays a list of files and folders in the current directory.
  • CD: Changes the directory.

For more detailed information, consult the official Microsoft documentation: CMD documentation.