197

I frequently find myself with a folder open in Windows, wishing to have a command prompt open with the same working directory.

I am aware of Power Toys "Command Prompt", but that only works as a context menu item on the folder, and not from inside the folder if you are already there. I know you can navigate to the parent directory, and use it from there, but if the parent has thousands of directories in it, this is not so convenient. I have tried some home-brewed batch files associated with folder actions in explorer, but those suffer from similar problems.

So, what is the quickest way to open a command prompt with a working directory of the current windows explorer folder?

My current approach: (horrible)

  • Alt - D, Ctrl - C (copy path)
  • Win - R, "cmd", Enter (start command prompt)
  • "cd", Space (start a change directory command)
  • Alt - Space, e, p (paste directory)
  • Enter (execute change directory)

I know there is something better! What is it?

5
  • 6
    It's not specifically about a programming language, but the only reason I ever need to do this is because of something programming related, and I am sure others have encountered it as well.
    – recursive
    Dec 18, 2008 at 16:16
  • 3
    @Daok I think you are too strict.Just look for questions tagged with 'command-line':'What is the safest way to empty a directory in *nix?','How can I diff two files with full context?',etc. Many programmers use cmd line which affects their productivity. I think it's valid question not related to IT. Dec 18, 2008 at 16:50
  • Well for what it is worth, I feel that it really is an OS question. It is true that the OS definitely does effect programming, but everything in the programmer's life does and you have to draw the line somewhere.
    – EBGreen
    Dec 18, 2008 at 16:59
  • 2
    @Daok: Get off your high horse! Programmers often need tips about how to do their jobs faster; quickly getting to a command line is one of them. You need you moderator privileges revoked, IMHO. Dec 18, 2008 at 17:57
  • 1
    @recursive: Google for this; I found a small registry change for Windows XP that worked for any file in the folder, I think... but it was a long time ago, and I wanted to click the folder so I didn't pursue it. Dec 18, 2008 at 18:00

14 Answers 14

440

Hold Shift while Right-Clicking a blank space in the desired folder to bring up a more verbose context menu. One of the options is Open Command Window Here. This works in Windows Vista, 7, 8, and 10. Since Windows 10 Creators Update, the option has been replaced with Open PowerShell Here. However, there are ways to enable Open Command Window Here again.

7
  • 2
    This works from vista above. You can also shift+click on some folder itself
    – phuclv
    Feb 18, 2014 at 3:40
  • It also works in Windows XP, the difference is that you must click on the folder icon itself.
    – neves
    May 28, 2014 at 18:17
  • 2
    Full keyboard solution (Windows 7): SHIFT+F10 to open the context menu, then press the letter associated to the command prompt ("f" in french). Cocorico :-)
    – user1636522
    Mar 3, 2015 at 18:51
  • @procrastinator F10 is to open the main menu. The context menu is opened by the menu key (the key between right Alt and right Ctrl), so you can use Shift+Menu
    – phuclv
    Nov 11, 2016 at 8:53
  • 1
    Those loking to get it back thnx to Win10CU,take ownership of and rename HKEY_CLASSES_ROOT\Directory\shell\cmd,HideBasedOnVelocityId key (add an underscore prefix or something) and command prompt option returns! (ref) Jun 12, 2017 at 21:10
329

Just type "cmd" to location bar, that's it. It will start a new command prompt in current path.

This solution was confirmed to work in Windows XP, Vista, 7, 8 and 10 (including Creators Update).

Keystrokes to move the focus to the location bar:

  • AltD in English (pointed out by Tim Stewart in the comments)
  • AltE in German
11
  • 8
    This trick also works with PowerShell for Windows 7/8/Server 2008+. Typing powershell in the command bar will bring up a powershell window set to that directory.
    – Laurence
    Sep 24, 2013 at 18:51
  • 3
    I love this mouseless approach. The only thing is that is will not work from a UNC location (\\server\sharename). Then you'll need to use shift right-click, Open command window here. A network drive will be created on the fly.
    – mgr326639
    Apr 20, 2014 at 20:59
  • 1
    And if you're too lazy to even do this, you can use this autohotkey script to map it to CTRL+T: #IfWinActive ahk_class CabinetWClass ^T:: Send !dcmd{Return} return #endif Oct 30, 2014 at 20:26
  • 5
    how about cmd as Administrator?
    – serge
    Feb 2, 2016 at 10:52
  • 1
    @Dave45 Microsoft wants to promote PowerShell.
    – Lupilum
    Jul 27, 2017 at 5:02
30

Inside your current folder, simply press Shift+Alt+F --then--> Enter.

The prompt will appear with your current folder's path set.

Note: That works only in Windows 7 / Vista. What it does is that drops the "File" menu down for you, because the "Shift" key is pressed the option "Open command window here" is enabled and focused as the first available option of "File" menu. Pressing enter starts the focused option therefor the command window.

Edit:

In case you are in a folder and you already selected some of its contents (file/folder) this wont work. In that case Click on the empty area inside the folder to deselect any previously selected files and repeat.

Edit2:

Another way you can open terminal in current directory is to type cmd on file browser navigation bar where the path of current folder is written.

In order to focus with your keyboard on the navigation bar Ctrl+L. Then you can type cmd and hit Enter

3
  • 2
    In Windows Explorer on Windows 7, that merely drops the file drop down menu for me.
    – recursive
    May 16, 2014 at 16:21
  • 1
    Works for me (Windows 7 Professional) Aug 7, 2014 at 17:15
  • 1
    The real gem here is that holding shift while accessing the File menu shows this command. Easier to remember than the key combo and I'm betting it works on Windows 10 too.
    – RoG
    Jun 29, 2016 at 6:31
29

Right-click the title-bar icon of the Explorer window. You'll get the current folder's context menu, where you'll find the "command window here" item.

(Note that to see that menu item, you need to have the corresponding "power toy" installed, or you can create the right registry keys yourself to add that item to folders' context menus.)

2
  • Cool. Is there a way to do that with the keyboard?
    – Hugh Allen
    May 6, 2009 at 0:48
  • 11
    Hugh, please see fm's answer: type "cmd" into the address bar. Based on the question's text, I gather you can get to the address bar with the keyboard with Alt+D. May 7, 2009 at 6:16
28

As a very quick solution I can give you this. I tested this on Windows 8.1

1- Find File and Right Click on Command Prompt on File Explorer and then add command prompt to your Quick Access Toolbar:

Instruction 1

2- After adding it you can access the folder from here:

Instruction 2

That will open a command prompt in there for you.

4
  • well thought out! People using W7 see my answer below. Nov 26, 2014 at 3:18
  • This also works on Windows 10.
    – ctype.h
    Sep 22, 2015 at 4:31
  • This is useful for most cases but I sometimes just drag folders and files to the desktop when working with a small amount of stuff. It just means that I don't need to make a new directory to put things from multiple directories into one place. Would be awesome if there was a solution for the desktop. Nov 25, 2016 at 6:32
  • 1
    This was removed in the Windows 10 Creators Update. Powershell still remains though. Sep 29, 2017 at 18:12
22

On vista and windows 7:

  • Alt+d -> it will put focus on the address bar of the explorer window
  • and then, type the name of any program you would launch using WIN+r
  • hit Enter

The program will start with its current directory set to that of the explorer instance. e.g.:python, ghci, powershell, cmd, etc...

12

You can edit the registry to add the Command Prompt item to the context menu. Here are a couple of .reg files that I use.

Cmdhere.reg - for WinNT/2000/XP/Vista/7:

Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\shell\OpenNew]
@="Command Prompt"
[HKEY_CLASSES_ROOT\Directory\shell\OpenNew\Command]
@="cmd.exe /k cd %1"
[HKEY_CLASSES_ROOT\Drive\shell\OpenNew]
@="Command Prompt"
[HKEY_CLASSES_ROOT\Drive\shell\OpenNew\Command]
@="cmd.exe /k cd %1"

Doshere.reg - for Win9x:

REGEDIT4
[HKEY_CLASSES_ROOT\Directory\shell\OpenNew]
@="MS-DOS Prompt"
[HKEY_CLASSES_ROOT\Directory\shell\OpenNew\Command]
@="command.com /k cd %1"
[HKEY_CLASSES_ROOT\Drive\shell\OpenNew]
@="MS-DOS Prompt"
[HKEY_CLASSES_ROOT\Drive\shell\OpenNew\Command]
@="command.com /k cd %1"

Copy this into an empty text file and change the extension to .reg. Double-clicking on this in Windows Explorer will add these key to the registry.

5
  • Used this and works perfectly :). But, how can I have a similar option with elevated privileges (will prompt for UAC naturally)?
    – Kounavi
    Feb 7, 2013 at 21:10
  • 2
    All I needed to do was add a reg for HKEY_CLASSES_ROOT\Folder\shell, rather than Directory and Drive
    – drzaus
    Jul 26, 2013 at 18:23
  • 1
    It doesn't work on my Win 10, %1 param should be embraced with quotes like this: command.com /k cd "%1" And for Drive it doesn't work because cd command could not change current drive.
    – Allen
    Aug 10, 2015 at 2:37
  • In Windows 10 use File -> Open Windows PowerShell. For help on command use (for example): Get-Help mkdir
    – amuliar
    Nov 20, 2017 at 14:47
  • cmd /k cd "%v\." worked for me in Computer\HKEY_CLASSES_ROOT\Directory\Background\shell\cmd here\command Sep 3, 2021 at 22:28
12

For Windows vista and Windows 7 ,to open the command prompt 1) go to folder you want to work

2)In address bar type- cmd

press enter

it will open the command prompt for that location

2
  • this answer was given already five years before you. Why do people post identical answers over and over? May 4, 2017 at 2:58
  • @Shirish thanks for the tip. your answer helped to save lot of time. worked in win10. Apr 18, 2018 at 16:26
10

I use StExBar, a Windows Explorer extension that gives you a command prompt button in explorer along with some other cool features (copy path, copy file name & more).

https://tools.stefankueng.com/StExBar.html

EDIT: I just found out (been using it for more than a year and did not know this) that Ctrl+M will do it with StExBar. How's that for fast!

4

Almost the same as yours:

  • Alt+d, Ctrl+c
  • Win+r
  • cmd /K cd , Ctrl+v, ENTER
2
  • Excellent! The last line seems like it should be "cmd /K cd /D", Ctrl+v, ENTER For posterity.
    – recursive
    Dec 18, 2008 at 16:22
  • 2
    You may need "s if there are spaces in the path.
    – EBGreen
    Dec 18, 2008 at 16:29
3

If that's so bothering, you could try to switch to windows explorer alternative like freecommander which has a toolbar button for that purpose.

2

I use a lot the "Send To" functionality.
I create my own batch (.bat) files in the shell:sendto folder and send files/folders to them using the context menu (to get there just write 'shell:sendto' in location bar).
I have scripts to perform all sort of things: send files by ftp, launch a php server in the current folder, create folders named with the current date, copy sent path to clipboard, etc.
Sorry, a bit offtopic but useful anyway.

2

Tried the answer given by Tough Coder in Windows 7 and it works!

Create a shortcut to cmd.exe in %HOMEDRIVE%%HOMEPATH%\Links, open its file properties and change the field 'Start at' to %1 ('Iniciar en' translated from spanish).

Now drag folders to it and you'll see the magic. It works too in all standard Open File dialogs. wow!

ps: those 'strange' tabs above in my picture are because I use Clover. I recommend it!

enter image description here

-2

Use the following in command prompt to open your current location in windows explorer:

C:\your-directory> explorer .

1
  • 1
    off topic, the Q is about the other direction, opening CMD from Explorer. May 28, 2015 at 15:45

Not the answer you're looking for? Browse other questions tagged or ask your own question.