Saturday, March 1, 2008

Open cmd From Right Click Menu

Often, when using Windows Explorer, I want to open the command prompt at the folder that's my current location. That takes too many steps: opening a command prompt and then navigating to my current folder.

However, there's a quicker way: add an option to the right-click context menu that will open a command prompt at your current folder. For example, if you were to right-click on the C:\My Stuff folder, you could then choose to open a command prompt at C:\My Stuff.

To add the option, run the Registry Editor, then go to HKEY_LOCAL_MACHINE/Software/Classes/Folder/Shell. Create a new key called Command Prompt. For the default value, enter whatever text you want to appear when you right-click on a folder—for example, Open Command Prompt. Create a new key beneath the Command Prompt key called Command. Set the default value to Cmd.exe /k pushd %L.

That value will launch Cmd.exe, which is the XP command prompt. The /k switch puts the prompt into interactive mode. That is, it lets you issue commands from the command prompt; the command prompt isn't being used to issue only a single command and then exit. The pushed command stores the name of the current directory, and %L uses that name to start the command prompt at it. Exit the Registry.

The new menu option will show up immediately. Note that it won't appear when you right-click on a file; it shows up only when you right-click on a folder.

No comments: