Use the PushD & PopD commands for quick network drive mapping in Windows 7

Greg Shultz shows you how to use PushD and PopD to save time and aggravation when you need to use temporary drive mapping.

Have you ever needed to temporarily map a drive letter to a network location for a quick file operation while you were working from a Command Prompt? Of course, you can switch over to Windows Explorer and use the Map Network Drive command. However, that requires multiple steps to create and then you have to perform several more steps to disconnect the network drive. This can be a pain, especially when you're working from a Command Prompt. Fortunately, you can use a pair of often-overlooked Command Line tools still available in Microsoft Windows 7 -- PushD and PopD -- to quickly map network drives.

In this edition of the Windows Desktop Report, I'll show you how to use PushD and PopD for temporary drive mapping. As I do, I'll explain how these two old DOS utilities work.

This blog post is also available in the Slideshow Photo Gallery format.

The Map Network Drive command

Just for the sake of comparison, let's begin by taking a look at all the steps involved in temporarily mapping a network drive in Windows Explorer. When you need to map a network drive from within Windows Explorer you can pull down the Tools menu and select the Map Network Drive command. If you are running Windows 7 with its context-sensitive Command Bar, when you open Computer, the Map Network Drive command will appear on the Command Bar, as shown in Figure A.

Figure A

In Windows 7, the Map Network Drive command appears on the Command Bar.
When you see the Map Network Drive window, as shown in Figure B, you use the Drive drop-down to select a drive letter. Then, you can use the Folder drop-down to select a drive you've previously mapped or click the Browse button and use the Browse for Folder dialog box to locate the network folder that you want to map to a drive. Be sure to leave the Reconnect at Logon check box unselected.

Figure B

If you have connected to the drive before, you can find the network path on the Folder drop-down.
When you are done using the drive, you must then return to Windows Explorer, pull down the Tools menu, and then select the Disconnect Network Drive command. When you see the Disconnect Network Drive dialog box, as shown in Figure C, just select the drive icon and click OK.

Figure C

To disconnect, just select the icon and click OK.

As you can see, using Windows Explorer's network drive mapping feature really isn't that complex, but it does require a multitude of steps. This is especially apparent when you see how quickly the same operation can be performed using the PushD/PopD commands.

The PushD/PopD commands

As you may know, the PushD and PopD commands have been around since Windows 2000 and are powerful little commands that can save you quite a bit of time when you are working on the Command Prompt. However, they are often overlooked.

Basically, the PushD/PopD commands are used to maintain a history list of directory paths in what is called a directory stack. In addition, these commands function like the Change Directory (CD) command.

The syntax for the PushD command is:

pushd [path]

When you use it, the PushD command stores the current path in the directory stack and then immediately changes to the specified path. When you use the PopD command, it retrieves the path at the top of the stack and changes to that path.

For example, if you are currently in the C:\Users\Greg\Documents directory and you type the command:

pushd c:\users\public

Then the C:\Users\Greg\Documents path is stored in the directory stack and the current directory becomes C:\Users\Public. When you are done working in the C:\Users\Public directory, you just type:


When you do, the C:\Users\Greg\Documents path is retrieved from the directory stack and the current directory becomes C:\Users\Greg\Documents. This example is shown in Figure D.

Figure D

The PushD and PopD commands in action.

Mapping network drives

In addition to making it easy to change back and forth between directories, the PushD and PopD commands also work with network paths. When working with network paths, the syntax for the PushD command is:

pushd \\Server\Share\path

Where \\Server\Share\path is the network resource to which you want to map a drive letter. As soon as you use it, the PushD command will instantly map a drive letter to the network resource and then change to that drive right in the Command Prompt window. When you're done, just type PopD and the mapped drive letter will be disconnected and you'll return to your original drive.

Keep in mind that the PushD command allocates drive letters from Z: on down and will use the first unused drive letter that it finds.

Figure E illustrates the same network mapping procedure that I showed you earlier in Windows Explorer.

Figure E

Mapping a network drive with the PushD and PopD commands is a piece of cake.

What's your take?

Have you used the PushD and PopD commands before? Have you ever had the need to set up a temporary drive map while working from the Command Prompt? Are you likely to use PushD and PopD commands to temporarily map a drive letter from the Command Prompt? As always, if you have comments or information to share about this topic, please take a moment to drop by the TechRepublic Community Forums and let us hear from you.

Also read:


Greg Shultz is a freelance Technical Writer. Previously, he has worked as Documentation Specialist in the software industry, a Technical Support Specialist in educational industry, and a Technical Journalist in the computer publishing industry.


So for a transitory mapping in a script to a network resource to which you have access this is OK. Most of the time I need the authentication provided with NET USE to reach a resource. Hint, NEVER use persistent drive mappings. If you know how to use NET USE then put it in a script (i.e. MyMapping.cmd) and run it when needed (also unmap the drive when no longer needed). This will save you many headaches. It is a bit more advanced but you can have the script check if you are on the network where you mapping will work before mapping the drive. ----------------------------------------------------------------------------- For those who want to know why persistent mappings are bad in a corporate environment and not recommended at home... Persistent mappings are a major cause of slow response to opening Windows Explorer, My Documents, finding or saving files (save-as dialog) among other items. Microsoft has these actions check that network resources are available each time one of these is used. And these lurk in unlikely places in what people do on computers. What happens is these actions all try to connect to each network reasource including the non-present items. This can mean say 60 - 90 seconds (or longer) per item not available. Not to mention the time for each item that is available to respond. So, instead of the "File -Save As" dialog opening up in 5 to 10 seconds, it can take 3 or 4 minutes (and I have seen 30+ minutes for extreme cases). This is especially true in larger WAN based network topologies where response time is much slower and timeouts may be set to a longer interval. Many times persistant mappings are used to connect to someone elses computer, not a server. Now you have computers that are not always on or laptops that go on trips. Every mapping to a system that is not available makes anything that touches a network resource have to wait for the system to time out attempting to connect to EACH ITEM that is no longer available. Example: Why is Word or PowerPoint so slow to open a file? Unfortunately in the WYSIWYG new world, Office checks the printer before showing the document. Well you have a network based printer and there are 2 persistent drive mappings to things that no longer exists. Luckily it usually checks just the default printer and not each printer defined on the system. And sometimes people wonder why I made all clients I support default to NOT REMEMBER network connections.


1) On almost every machine B: is available to be mapped as a network drive. net use B: \\server\share works just fine And A: too on many/most machines 2) When doing a net use an asterisk can be used which says use the next available drive letter. net use * \\server\share


for permanent and persistent drive mappings i still prefer " Net use z: \\ /persist:yes " but i could see myself using these pushd/popd commands for scripting and for assigning a drive for temporary file swapping...... but actually it takes the first available drive maybe not without some extra lines of code to determine which drive letter it took each time.....


In Unix / Linux yes ... but I never knew it existed in Windows


Have never used those commands before. After all these years and I did not realize they existed. I've always mapped drives on the fly using 'net use x: \\server\path' then deleting it when done. But you have to know what drive letters are available to do that. Since my users all use the same drives, I'm pretty safe in selecting one.

Mark W. Kaelin
Mark W. Kaelin

Do you still use the command line often or have you become more dependent on the GUI for your maintenance work?


I also prefer 'net use',in batch files for the reason you noted: control over the drive letter assigned. Greg is right though; I'd forgotten them. 'Net use' had become a habit in previous versions, and I've never gotten around to applying the newer methods.