Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How does one set the title of the of the Command Prompt (CMD) in Windows XP to the current working directory dynamically ? I can use

title %CD%

however, this is a temporary fix and the title remains fixed when I change directory using the CD command.

share|improve this question
Well, what happens when you use pushd with one of the macros? –  Hello71 Jul 5 '10 at 21:27

5 Answers 5

up vote 10 down vote accepted

Got it to work thanks to gravvity's doskey macro. He has used && to combine the cd and title commands which works perfectly. I even made this macro load every time I use cmd by tweaking the registry.

1) I created a bat file called cmd_title.bat and it contents are

@echo off
title %cd%

2) I placed this file in the C: drive (C:\cmd_title.bat)

3) Create another batch file called cmd.bat in the C: drive with the following contents

doskey cd = cd /d $* ^&^& "C:\cmd_title.bat"
title %cd%

(the /d flag is for using cd to switch to another drive).

4) Then we open regedit and go to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor. Here there is a key called AutoRun. We modify the value of this key and set it to the location of the cmd.bat file in quotes (eg: "C:\cmd.bat").

Now cd works as we want every time we open cmd.

Basically && is used for command chaining in Windows

share|improve this answer
Cool, I got your solution to work. But I lost my "hit tab key, auto-match" functionality. –  rok2791SWTS Sep 9 '10 at 17:39
You might have disturbed the CompletionChar/PathCompletionChar values in the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor key in the registry. To set use the tab key for auto-completion you need to set the CompletionChar and PathCompletionChar values to 0x9 (hex) –  Stormshadow Sep 10 '10 at 5:44
+1 it is a working solution, but with minor correction: AutoRun is not a key, but value of type of string. –  mloskot Dec 6 '11 at 23:53
When we shift+right click on a folder in windows explorer, we have an option for opening command prompt on that folder. This solution doesn't work in that case. Does anyone know a quick fix to this? –  bits Feb 26 '13 at 19:13
@bits There is a solution to make it work with shift+right click here: superuser.com/questions/414155/… –  kapep Oct 15 '14 at 22:56

I think that pushd and popd are much more useful than cd, and would see a lot more use if they were quicker to type. I have resolved the issues of cd vs. pushd/popd and console window directory title with the following script, which I call d.bat, which is in my path.

@ echo off
rem d.bat replaces CD, PUSHD, and POPD with one command that also changes the title
rem of the console window to tell the current directory. Invoked with no arg, the
rem title is updated. Use this after changing the directory by some other means.
rem The argument / invokes popd. Any other argument invokes pushd with that arg.

if not _%1 == _ ( 
    if _%1 == _/ (
    ) else (
        pushd %*
title %CD%
share|improve this answer

You can change the Command Prompt's title by using the title command.

You may create a batch file (say mycd.bat) containing:

title "%1"
cd  "%1"

and use it instead of "cd" :

mycd "newdir"

You can also put the .bat file in system32 if you wish it to always be available.

share|improve this answer
Using macros would be a better option: doskey cd=cd $* ^&^& title $* –  grawity May 20 '10 at 13:17
@grawity: Good idea. –  harrymc May 20 '10 at 14:53

You can't, at least not with the Windows shell.

It might be possible to add "set Xterm title" escape sequences to %PROMPT%, but you would need a different terminal emulator (perhaps PuTTYcyg or something from SfU), as Windows Console does not support escape sequences.

Alternatively, find another shell which can use the Windows console functions to set titles.

These are often confused in Windows contexts, so...

shell reads and interprets input; cmd.exe, command.com, /bin/sh

terminal, terminal emulator, console displays text-based programs (including the shell) on your screen; Windows Console, xterm, PuTTYcyg

share|improve this answer
actually, cmd.exe is a terminal. explorer is a shell. –  ldigas May 20 '10 at 13:09
@Idigas: explorer is a GUI shell, cmd.exe is a text-based one. (Think about it: cmd.exe is the exact equivalent of /bin/sh in Unix, and /bin/sh is always called "the shell". Similarly, the Windows Console is equivalent to a "terminal emulator" in X11.) –  grawity May 20 '10 at 13:14
I stand corrected. –  ldigas May 20 '10 at 13:54

Assuming \tools is in the path, and it's where you keep your batch files:

copy con: \tools\titlecmd.txt

title ^Z

copy con: \tools\cdtitle.bat


copy \tools\titlecmd.txt+\tools\cd.txt cdtitletmp.bat

call cdtitletmp


You now have a cdtitle.bat that you can call from another batch file.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.