PUSHD – Windows CMD Command

Change the current directory/folder and store the previous folder/path for use by the POPD command.

If the drive is not specified, the current drive will be assumed.
If neither drive nor path is specified PUSHD will just display a list of previous pathnames, you can switch back to any of these by using POPD one or more times.
The number of pushed directories can be displayed on the command line with PROMPT $+
If the path specified does not exist, PUSHD will return %errorlevel% =1

Run as Admin

When a batch script is ‘Run as Admin’, the current directory will be set to C:\windows\system32\.
Using the following pushd command at the start of the script will restore the normal current directory.

This works by setting the current directory to the location of the batch script, using the %0 parameter

pushd “%~dp0”

UNC Network paths

When a UNC path is specified, PUSHD will create a temporary drive map and will then use that new drive.
The temporary drive letters are allocated in reverse alphabetical order, so if Z: is free it will be used first.


If the Current directory was changed: %ERRORLEVEL% = 0
If the Directory does not exist or is not accessible or if a bad switch is given: %ERRORLEVEL% = 1

PUSHD is an internal command. If Command Extensions are disabled the PUSHD command will not accept a network (UNC) path.

You may also like...

1 Response

  1. zortilo nrel says:

    I believe this is one of the so much vital information for me. And i’m satisfied studying your article. But wanna commentary on some common issues, The website style is wonderful, the articles is really nice : D. Just right task, cheers

Leave a Reply

Your email address will not be published. Required fields are marked *