Can I add a Windows Explorer context menu option to start command prompt in the selected directory?

9

2

When browsing in Windows Explorer, sometimes I want to start a command prompt "here", e.g. with the current browsed folder as the current directory.

For example, when I am browsing "D:\Foo\Bar\Bar1", I want to open the command prompt with current dir pointing to this directory. Normally what I do is

  1. Copy the current folder path from Windows explorer's address bar
  2. Open cmd via Start Menu > Run
  3. Type D: (because I have to change drive, the default is C:)
  4. Type "cd " and then paste the folder path that I copied earlier

I do it quite often in my daily work, and I think by adding a context menu I will improve my efficiency (and also having to do the above repeatedly can be kind of annoying). I imagine I can just Right-Click > Start cmd here and then I will have a command prompt already in D:\Foo\Bar\Bar1

Is this possible?

Louis Rhys

Posted 2013-04-08T10:25:09.600

Reputation: 1 543

any reason for downvote? – Louis Rhys – 2013-04-09T16:20:38.747

Answers

13

  1. Start / Run / regedit

  2. Navigate to the following keys in turn:

    HKEY_CLASSES_ROOT\Drive\shell\cmd
    HKEY_CLASSES_ROOT\Directory\shell\cmd
    HKEY_CLASSES_ROOT\Directory\Background\shell\cmd
    
  3. Under each in the right pane you'll see a REG_SZ string value called Extended. Just rename this to something else (in case you want to easily undo the change) or delete it (just that value):

    1

  4. Now you can simply right-click a drive or directory and have the Command Prompt option show up without having to press Shift.

Karan

Posted 2013-04-08T10:25:09.600

Reputation: 51 857

+1 cool. However, it still didn't show up when clicking on empty space in folder (it shows up when pressing shift). Any idea? – Louis Rhys – 2013-04-08T16:24:48.910

@LouisRhys: See my edited answer above. – Karan – 2013-04-08T16:48:33.223

1that's cool! Do you happen to know if it's possible to rearrange the position of the menu too? – Louis Rhys – 2013-04-09T01:42:24.647

As in, move the Command Prompt option to another position? Unlikely since one can't control where other programs add their entries, but I'll look into it and let you know. – Karan – 2013-04-09T11:48:39.713

15

Right-click on the folder itself with Shift held down, and a new context item should appear named Open command window here.

This trick also works if you do it in the empty space of a folder.

Sir Crispalot

Posted 2013-04-08T10:25:09.600

Reputation: 273

1+1 that's nice. Makes me wonder why it only appears with Shift – Louis Rhys – 2013-04-08T11:52:18.120

2@LouisRhys: Because it has the Extended verb set. See my answer to know how to disable the verb. – Karan – 2013-04-08T12:39:10.463

7

Just type "cmd" in Windows Explorer's address bar.

user266088

Posted 2013-04-08T10:25:09.600

Reputation: 109

Upvoted for this nice trick. Wasn't aware of this – AcidJunkie – 2014-11-17T06:14:26.143

I know OP’s question was for Win7 but for Win8 and upwards MS finally implemented Ctrl+L (like all browsers that I‘m aware of) to set focus to the address bar. So for Win10 I hit Ctrl+L and then type cmd. One downside is that the path then changes to "C:\Windows\System32\cmd.exe" which is annoying as hell, I guess this also happens in older Windows versions. See https://superuser.com/q/1451924/389874 for this problem, unfortunately no solution yet.

– bugybunny – 2019-08-21T07:08:17.807

2This fails completely to answer OP's question. Could you at least take some time to clarify your answer and explain your reasoning? – DanteTheEgregore – 2013-10-23T05:22:00.120

4Have you tried it? This definitely works in Win-7 (a tag applied to the OP), and probably in Vista; it doesn't in XP. – user266088 – 2013-10-23T09:36:14.637

2Did you bother to even read OP's question? He's looking for a way to spawn a CMD in the current directory he has open in Explorer via the context menu. Your suggestion just spawns a CMD. He'd still have to CD over to his current directory which doesn't help at all. – DanteTheEgregore – 2013-10-24T03:00:41.740

6Not in Windows Vista & 7 where the method I described works. This works for other console programs as well, e.g. Powershell.exe or tcc.exe. This behaviour has been described on various other forums, e.g. lifehacker, stackoverflow, jpsoft. I don't think that the OP wanted to limit any solutions to a context menu. – user266088 – 2013-10-24T10:21:00.350

@user266088 this is an excellent trick!! If I could multiple vote up I'd do it! I guess I've not been looking at other forums for this, since I was happy with my solution listed as an answer to another question. My solution works even on files in any explorer context menu BTW.

– LMSingh – 2014-03-19T18:17:43.317

Upvoted. This is correct for Windows 7 Professional, and I never knew it. It's certainly easy enough to hit "ALT+D" to get the address bar, "CMD[ENTER]" and voila-- command prompt at the current directory. – Wally – 2014-03-19T20:36:50.903

1

A fast alternative on Windows 10 is to hit Alt, D, E in succession and the command prompt will open on the current open Explorer path. Sorry for the german, but you get the point.

Alt, D shows you this menu

Tomas Ruiz

Posted 2013-04-08T10:25:09.600

Reputation: 11

1In English versions, the shortcut would be Alt, F, P – w32sh – 2016-07-09T10:04:11.507

@w32sh That open a properties dialog for me on Windows 7, which is what the question is tagged. – DavidPostill – 2016-07-10T11:04:56.557

My mistake. Thought I was in Windows 10 topic area. – w32sh – 2016-07-10T11:37:57.040

0

Without registry edit, you can achieve this with an answer to a similar but slightly different question (How do I get a right-click command line for a folder?). Works in all versions of Windows NT onwards.

LMSingh

Posted 2013-04-08T10:25:09.600

Reputation: 807

-1

You could remove 2 steps from your workflow by doing the following:

  1. Copy the current folder path from Windows explorer's address bar
  2. Start Menu -> Run -> Type cd /D "D:\Foo\Bar\Bar1 >> cmd

The command cd /D "D:\Foo\Bar\Bar1 >> cmd opens a cmd with the directory set to D:\Foo\Bar\Bar1

I hope that helps!

Simon

Posted 2013-04-08T10:25:09.600

Reputation: 3 831