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 can I create a desktop shortcut that opens up Command Prompt (cmd) in a specific folder? I'm getting tired of navigating from my home directory to my development directories.

share|improve this question

3 Answers 3

up vote 11 down vote accepted

Create your shortcut and then right click to get the properties dialog and set the "Start in:" property to be your folder.

setting the start folder

share|improve this answer
1  
grrrr .. 44secs .. grrr :) –  akira Mar 7 '11 at 21:37

There's more than one way to skin this cat, for sure.


A batch file could also do it for you. This will start you off in the Program Files directory on the C drive:

@ECHO OFF
CD /D "C:\Program Files\"
CMD

Especially make sure to use the /D switch, if you're changing to a different drive than where CMD normally starts you.


The Open Command Window Here PowerToy for Windows XP is also rather handy for going straight from an Explorer session, into a CMD console at a certain directory.


You can use the AutoRun string value in one of the following Registry keys, to essentially automate the above for all CMD sessions.

For your account only:

HKCU\SOFTWARE\Microsoft\Command Processor\

For all users on this machine:

HKLM\SOFTWARE\Microsoft\Command Processor\

If the AutoRun value doesn't exist, create it as a REG_SZ type (also known as String Value). For Data, you can either put the path to a batch file like the one above (remove the ECHO and CMD lines) or just insert the CD command as shown in the above example.

The up-side of pointing the Registry to a batch file, instead of just adding the command, is that you can add in as many AutoRun commands as you like to the batch file. This way you can create custom prompt formats or script other tasks you want done at every launch of CMD.

One thing to keep in mind if you make these Registry changes though, is that they may affect the behavior of other batch files. Particularly, batch files may find themselves not starting in the directory they were originally written for.

As always, backup your Registry before making any untested changes.

share|improve this answer

or you could just use a target string similar to this: C:\Windows\system32\cmd.exe /k "c: & cd c:\drv\bat"

Obviously C:\Windows\System32\cmd.exe is to run cmd. The "/k" carries out the command by string and continues. The string is the "c: & cd c:\drv\bat". Within the string, the "C:" just changes the drive letter. The "&" ties both commands together. And the "cd c:\drv\bat" is basically a change directory. Also one thing to note, the "cd c:\drv\bat" should also change drives.

share|improve this answer

Your Answer

 
discard

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.