adrift in the sea of experience

Friday, November 19, 2010

An equivalent of .bashrc for the windows cmd.exe shell

Tired of the "cd" command in windows refusing to navigate to folders on other drives? Put this in the [HKEY_CURRENT_USER\Software\Microsoft\Command Processor] AutoRun key:

c:\cmdauto.cmd

This will cause the given script to be executed each time a cmd.exe window is opened. I found out about that thanks to this superuser.com post.

Now put this in c:\cmdauto.cmd

@echo off
doskey cd=pushd $*

The doskey command creates aliases, here overriding the behavior of "cd".

2 comments:

eric said...

This is by far the best thing I have ever found for Windows cmd!!!

Before this, I had to execute:
doskey /MACROFILE=foo.txt

each time I started a cmd session.

Thanks for the tip!

Meghashyam Sandeep Vakacharla said...
This comment has been removed by the author.