You are here.

Mega-ZBlog header image

Display the Path in the Command Prompt Title Bar

August 27th, 2008 · 11 Comments · Windows

Well I messed around a bit and came up with a rather nice solution. This emulates a feature of Linux’s gnome-terminal where you can set the titlebar to always reflect the terminal’s current directory.

Scroll down for code and instructions, or read on for “the process”.

I used this as a basis, but there are a number of things wrong with that article. First of all, the %=c:% variable returns the current directory on C:, not on the current drive. Since everyone except maybe some ultralight laptop owners have more than just a C: drive (I spend most of my time on E:, F:, and G: myself) this is unacceptable to me.

I quick search turned up %cd% which returns the current directory. Much nicer.

Now we have another little problem in the form of an extra prompt line that appears. I discovered by inserting “echo off” (which suppresses the prompt) before the first command in the doskey macro, then “echo on” at the end, this problem goes away quite nicely. I was almost done.

Then I just have to duplicate this doskey macro for other commands the article fails to consider, for example pushd and popd, plus all the drive letters. A for loop takes care of the latter, although I still can’t avoid the tedious typing of every letter in the alphabet (I need to start using powershell or cygwin bash or something).

In the end, here is what I have. Place both files in your system path somewhere (C:\WINDOWS\system32 meets this requirement).


@echo off
doskey cd=echo off$Tcd $*$Ttitlepathhelper$Techo on
doskey chdir=echo off$Tchdir $*$Ttitlepathhelper$Techo on
doskey pushd=echo off$Tpushd $*$Ttitlepathhelper$Techo on
doskey popd=echo off$Tpushd $*$Ttitlepathhelper$Techo on
for %%x in (a b c d e f g h i j k l m n o p q r s t u v w x y z) do doskey %%x:=echo off$T%%x: $*$Ttitlepathhelper$Techo on


@title %cd%

You’ll notice titlepath takes a little bit to churn away… if it bothers you, you can remove some of the drive letters from the for list or remove that line completely if you don’t mind the title not updating when you change drives.

One last thing is if you want this to happen every time you launch a command prompt without having to type titlepath in.

Open HKEY_CURRENT_USER\Software\Microsoft\Command Processor in Registry Editor and make an AutoRun string value and set it to titlepath.cmd. Interestingly my batch file shouldn’t work at all according to this caveat, but I can’t get it to AutoRun when running through a for loop… odd.

Tags: ···

11 responses so far ↓

  • 1 Olivier Dagenais // Aug 27, 2011 at 1:56 pm

    Awesome, thank you for sharing! My console window titles are no longer this mysterious, opaque thing that I have to click on to find out which window is which, while secretly cursing the lack of a more *NIXish bash 🙂

    – Oli

  • 2 Johnny Baloney // Dec 9, 2011 at 10:39 am

    Nice! Thanks 😀

  • 3 Donnie // Sep 12, 2013 at 8:35 pm

    Thanks so much for this post!

  • 4 Jayce // Oct 1, 2013 at 11:41 am

    Awesome!!! Even though it doesn’t auto update, I usually stay in the same folder all the time anyways. The only reason I do change is because I can’t find the prompt i’m looking for! Now I can!


  • 5 ciprofloxacin cost walmart // Apr 25, 2020 at 5:35 am

    ciprofloxacin cost walmart

    Display the Path in the Command Prompt Title Bar

  • 6 albuterol inhaler // Apr 27, 2020 at 4:03 am

    albuterol inhaler

    Display the Path in the Command Prompt Title Bar

  • 7 viagra sales // Apr 28, 2020 at 2:02 pm

    viagra sales

    Display the Path in the Command Prompt Title Bar

  • 8 cialis no prescription // Apr 29, 2020 at 6:37 pm

    cialis no prescription

    Display the Path in the Command Prompt Title Bar

  • 9 chloroquine mexico over the counter // May 27, 2020 at 1:19 am

    chloroquine mexico over the counter

    Display the Path in the Command Prompt Title Bar

  • 10 hydroxychloroquine tablet price in india // Jun 3, 2020 at 2:03 am

    hydroxychloroquine tablet price in india

    Display the Path in the Command Prompt Title Bar

  • 11 buy cialis // Jul 1, 2020 at 1:02 pm

    buy cialis

    Display the Path in the Command Prompt Title Bar

You must log in to post a comment.