Clear, practical technology insights BSOD Code Lookup · Windows Error Code Lookup · Wi-Fi Troubleshooting · PC Troubleshooting Checklist

Popd and Pushd Commands in Windows

Understand Popd and Pushd Commands in Windows with clear explanations, practical examples, and useful tips. This updated guide covers the essential concepts...

Table of Contents

Popd and Pushd Commands in Windows is easier to understand when the core ideas are paired with practical examples. The sections below explain the topic clearly, highlight useful steps, and point out details that can prevent common errors.

(Applies to Windows Server (Semi-Annual Channel), Windows Server 2016, Windows Server 2012 R2, Windows Server 2012).

Popd command

Change the current directory to the folder stored most recently by the pushd command.For a better understanding of how to use this command, see the example below.

Syntax popd

 Popd 

Popd command parameter

Parameters

Describe

/?

Show help at thecommand prompt.

Popd command comment

  • Each time you use the pushd command, a single directory will be stored for you to use. However, you can still store multiple directories using the pushd command multiple times. Folders are stored sequentially in a virtual stack. If you use the pushd command once, the directory you use is located at the bottom of the stack. If you use the command again, the second folder is located at the top of the first folder. The process will be repeated every time you use the pushd command. Alternatively, you can use the popd command to change the current directory to the directory stored most recently by the pushd command. If you use the popd command, the folder at the top of the stack will be deleted from the stack and the current directory will be changed to that folder. If you use the popd command again, the next folder on the stack will be deleted.Just like that.
  • When the command extensions are enabled, the popd command will remove any drive letter assignments created by pushd .

Example popd command

the example below shows how you can use the pushd command and the popd command in abatch program(batch program)to change the current directory from a directory on which the batch program is run.Then change back:

 @echo off 
 rem This batch deletes t?p tin .txt trong m?t th? m?c ?ã ghi rõ 
 pushd% 1 
 del * .txt 
 popd 
 cls 
 echo các t?p tin v?n b?n ?ã xóa trong% 1 th? m?c 

Pushd command

Store the current directory for use by the popd command, and then change the specified directory.For a better understanding of how to use this command, see the example below.

Syntax pushd command

 pushd [] 

Pushd command parameter

Parameters

Describe

Specify the directory to create the current directory.This command supportsrelative paths.

/?

Show help at thecommand prompt.

Pushd command comment

  • Each time you use the pushd command, a single directory is stored for you to use. However, you can also store multiple directories using the pushd command multiple times. Folders are stored sequentially in a virtual stack. If you use the pushd command once, the directory you use is located at the bottom of the stack. If you use the command again, the second folder is located at the top of the first folder. The process will be repeated every time you use the pushd command.
  • Alternatively, you can use the popd command to change the current directory to the directory most recently stored by the pushd command. If you use the popd command, the folder at the top of the stack will be deleted from the folder. The current directory and directory will be changed to that folder. If you use the popd command again, the next folder on the stack will be deleted.Just like that.
  • If the command extension is enabled, the pushd command will accept either the network path or the local drive letter and path.
  • If you specify a network path, the pushd command temporarily assigns the highest unused drive letter (starting with Z:) to the specified network resource. The command then changes the current drive and directory to the specified folder on the newly assigned drive. If you use the popd command with extended command utilities enabled, the popd command will delete the drive letter created by pushd .

Example pushd command

  • Netcfg command in Windows
  • Nbtstat command in Windows
  • Bitsadmin create command in Windows
  • The nlbmgr command in Windows

FAQ

What should you know about popd command?

Change the current directory to the folder stored most recently by the pushd command.For a better understanding of how to use this command, see the example below.

What should you know about pushd command?

Store the current directory for use by the popd command, and then change the specified directory.For a better understanding of how to use this command, see the example below.

What is Popd and Pushd Commands in Windows?

(Applies to Windows Server (Semi-Annual Channel), Windows Server 2016, Windows Server 2012 R2, Windows Server 2012).

Discussion

Reader Comments 0

Sign in with email or Google to join the discussion.