windows command prompt change directory is now changing directory

I am trying to change directory from C drive to E drive. but the its not happening through following code.

C:\>cd E:\Program files\wkhtmltopdf

C:\>echo %cd%
C:\

It says C:\ is current directory evern after changing directory. Please correct my mistake.


This is normal behavior. CD stands for Change Directory. In order to change the drive, go to it by typing: E: followed by enter

C:\>E:_

E:\Program Files\wkhtmltopdf>_

It will remember your cd action though, so the new path should be what you've cd'd to.


Change the current drive

By default, the cd or chdir commands won't change the drive letter you're currently on; you need to use the /d parameter. For example:

cd /d E:

You can also use a specific path, if you want:

cd /d "E:\Program files\wkhtmltopdf"

As an alternative you can use the pushd (push directory) command, like this:

pushd "E:\Program files\wkhtmltopdf"

The main advantage over the cd command is that you can use popd to easily restore the previous working directory and drive. In addition, the pushd command also provides support to UNC paths.

Further reading

  • Command-Line Reference

The part of the answer that nobody else has explained is that Windows keeps track of (up to) 26 different current directories for each process (one for each drive), so, when you type

C:\> cd E:\Program Files\wkhtmltopdf

you are changing your E: working directory to \Program Files\wkhtmltopdf -- but (as the other answers have explained), you’re not changing your current drive to E:, so you don’t see the change in working directory.  (%CD% shows only the current directory on the current drive; it doesn’t show the other 25 current directories.)  So, you could type

C:\> cd E:\Program Files\wkhtmltopdf

and then

C:\> E:

and you would find yourself in E:\Program Files\wkhtmltopdf.  But that’s messy and confusing; use one of the techniques in the other answers.