How to Open a Window's Command Prompt to a Particular (non default) Directory

by Lonnie Lee Best
Lonnie Lee Best

Some programs, created for windows, offer a command line interface that you may want to frequent for performing certain tasks. Sometimes, using their command line interface requires you to open a command prompt and navigate to the program's root folder using dos commands. This article explains how to eliminate having to manually navigate to a program's root folder, by automating this task, with a batch file shortcut.

If you open a command prompt in windows (by clicking the Start Menu | clicking Run | typing: cmd | clicking "OK"), the command prompt's default location will be your user directory. The prompt will look something like this:

C:\Documents and Settings\UserName>

If you want to change directories, you can use the cd command. For example, if you wanted to move the command prompt to your "program files" directory, you could type:

cd "C:\Program Files"

Now the prompt will look like this:

C:\Program Files>

This is simple and easy, however, there are 3 reasons you may want to automate this process with a batch script:

  1. The "directory you desire to move to" has a long name that is cumbersome to type.
  2. The "directory you desire to move to" is very deep in the file system's hierarchy, which again, requires more typing.
  3. You frequent the directory so often, that you don't want to type its location each time.

By creating a simple batch script you'll be able to open a command window whose prompt is already at the directory you want.

Open Microsoft Notepad (Start Menu | All Programs | Accessories | Notepad).

Cut and paste the following into Notepad:

cmd /k cd "C:\Program Files"

Save this file with a ".bat" file extension instead of the (default) ".txt" extension: File | Save As | choose location (such as the desktop) | type "AnyName.bat" in the File name box *with quotes* | click "Save".

Now, go to where you saved the batch file (you've just created). Double clicking it should bring up a command window whose command prompt is already at the "Program Files" directory (we specified in the batch file).

I use batch files (like above) to quickly get to the command directories of (the window's versions of) MySQL and Matisse databases. I even use a keyboard management software so that I may hit a hot key, on my keyboard, and have the desired prompt immediately in front of me.

Tell others about
this page:

facebook twitter reddit google+

About the Author

Lonnie Best has been using the internet since 1993, and has been making web pages since 1995. visit:

Comments? Questions? Email Here


How to Advice .com
  1. Uncensored Trump
  2. Addiction Recovery
  3. Hospice Foundation
  4. Flat Earth Awareness
  5. Oil Painting Prints
Send us Feedback about