84

When I'm working in a folder in Windows Explorer, sometimes I have a need to run some CMD command in this folder.

How do I open the command line from a current folder, so the console opens in the current directory?

Example:

I work in D:\Apps\Test. I would like to have a possibility to open a command prompt with the same context (meaning: D:\Apps\Test), so I don't have to navigate to this folder again within a console, ie. so it opens cd'd to the current location.

EDIT: The solutions from this topic do not work for me, what's why I asked a separate question.

ᔕᖺᘎᕊ
  • 6,173
  • 4
  • 33
  • 45
boleslaw.smialy
  • 883
  • 1
  • 7
  • 13
  • @Dave : the solutions from this topic do not work on my station. – boleslaw.smialy Jul 29 '15 at 12:24
  • @Dave : ok, I got it. I will adjust next time. – boleslaw.smialy Jul 29 '15 at 12:33
  • 1
    Note that all answers to both this question and the linked question may not work as expected if the folder is a special system folder. For example, if you are in `Libraries > Documents`, the shift-right-click menu won't even offer the command prompt option, and the explorer bar option will open the cmd window to C:\Windows\system32 (it does work fine from `C:\Users\User_name\Documents`, though) – Dan Henderson Jul 29 '15 at 17:49
  • Shift-right click would let you open cmd in current directory. – Derek 朕會功夫 Jul 30 '15 at 02:14
  • All these solutions give a normal cmd. Are there any solutions for an elevated prompt? – Nzall Jul 30 '15 at 15:27
  • 1
    Why isn't this question closed as duplicate? "The solutions did not work for me" is not a good reason. The most voted answer here is a variant of [this answer](http://superuser.com/a/289459/18829). – Salman A Jul 31 '15 at 08:44
  • Elevated prompt can be done in Task Manager, left click on File, New Task while holding down the Ctrl key: http://winaero.com/blog/a-hidden-way-to-open-the-command-prompt-from-task-manager/ – Sun Aug 04 '15 at 23:32

9 Answers9

231

Enter cmd in explorer's address bar & press enter

enter image description here

clhy
  • 6,283
  • 8
  • 34
  • 66
  • 33
    OMG, I can't believe that actually works! +1 for both answers. :) – LPChip Jul 29 '15 at 12:22
  • 4
    Even better is that it works for other programs too! – afrazier Jul 29 '15 at 17:31
  • 1
    thanks for pointing that out afrazier, just tried with powershell and it worked great. (You would need to play around with registries to add a powershell entry to your context menu). – Xantix Jul 29 '15 at 23:37
  • 11
    also, for efficiency, ALT+D ,"cmd" , ENTER – Some_Guy Jul 30 '15 at 12:54
  • There seems to be a bug somewhere with this , if the Windows Explorer is on a server (\\server\folder1\folder2), and try CMD in the path, then it opens the console in "C:\windows. (weird). – Max Jul 30 '15 at 15:38
  • 3
    That's because you can't `cd` to a network drive unless it is mapped to a drive letter – Borodin Jul 30 '15 at 18:24
  • @Max & Borodin, **CreateFile C:\Windows\CSC\v2.0.6\namespace\fileshare NAME NOT FOUND** , this is the reason why it doesn't work when you try it over **\\file share** – clhy Jul 30 '15 at 19:53
  • @Some_Guy : Alt+D is the reason why i've asked this questions: it does simply not work on my station :) – boleslaw.smialy Aug 12 '15 at 06:49
  • @boleslaw.smialy are you pressing Alt then D or Alt + D ? – clhy Aug 12 '15 at 06:58
  • This still works in Windows 10 (unlike the SHIFT key answer). – Obiwahn Aug 15 '15 at 15:46
  • @Some_Guy even more efficient, `Shift+Menu`, W (might be different on other languages) – phuclv Nov 11 '16 at 08:57
133

You can also shift-right-click in a folder, and notice a new entry in the context menu (Open command window here):

http://i.imgur.com/nbfURik.png

Seiyria
  • 1,708
  • 2
  • 12
  • 14
  • 9
    Not sure why anyone would use the 'cmd' option over this. – Mdev Jul 29 '15 at 16:59
  • @Matthew I actually have problems where the option sometimes disappears from my menu, so I have to navigate manually. The `cmd` option will be great if I can remember it exists. – Seiyria Jul 29 '15 at 17:03
  • 3
    cmd in explorer bar gives you address to the current folder. Shift right-click gives you command prompt access to a subfolder. They have different use cases so I don't see a conflict here. – Sun Jul 29 '15 at 18:33
  • 11
    @sunk818 You can get the current folder also if you right click not on a folder. – Seiyria Jul 29 '15 at 18:54
  • 8
    @Matthew Press `Alt+D`, `C`, `M`, `D`, `Enter`. Very efficient. Your hands never leave the keys. (You can do `Shift`+`Menu` and then arrow down after arrowing to select the folder your want, but it's much less convenient.) – jpmc26 Jul 30 '15 at 00:27
  • @jpmc26 : this solution does not work for me, that's why I've opened this topic. – boleslaw.smialy Jul 30 '15 at 06:29
  • @Seiyria This option [doesn't appear in a library folder](http://superuser.com/questions/663216/why-cant-i-open-command-window-here-inside-a-library) (as opposed to a real directory), unfortunately. [There is a way to add it.](http://superuser.com/questions/620214/how-to-open-command-window-from-documents-library) – Bob Jul 30 '15 at 07:07
  • @Bob I bet that's why it sometimes wasn't there. Thanks for letting me know. – Seiyria Jul 30 '15 at 12:17
  • 1
    @boleslaw.smialy Do you have an inkling as to why it doesn't work for you? It works for me and I'm using Windows 7. Is there anything special you haven't mentioned? – MiniRagnarok Jul 30 '15 at 12:54
  • @Seiyria What you state is not true for me in Windows 7. It may not be delivered out of the box and possibly has to be customized to function that way. – Sun Jul 30 '15 at 16:44
  • +1 Unlike the accepted answer, this one will work if the current folder is a UNC path. It will temporary map a drive letter to the UNC path and unmap it when you exit the command window. – LeopardSkinPillBoxHat Jul 30 '15 at 21:48
  • @MiniRagnarok : I have no idea why that solution does not work for me. i have Win7 and local adm privileges. – boleslaw.smialy Jul 31 '15 at 06:23
  • @boleslaw.smialy What edition of Windows? If you type cmd into the search bar does the command line window come up? – MiniRagnarok Jul 31 '15 at 14:41
  • 1
    Broken in Win 10, right? – Obiwahn Aug 15 '15 at 15:45
  • @obiwahn No, it works just fine. – Seiyria Aug 16 '15 at 02:54
  • Oh, indeed. I had to deactivate StrokesPlus to make it work. – Obiwahn Aug 16 '15 at 08:22
  • @jpmc26 you can press `Shift+Menu` then press W (or any other underlined key for "open command window here" depending on your language), might be faster than Alt+D, cmd then enter – phuclv Nov 11 '16 at 08:56
40

How do I open Windows CMD in explorer from the current folder?

Enter cmd in the explorer address bar and press Enter

enter image description here

DavidPostill
  • 153,128
  • 77
  • 353
  • 394
  • 1
    followup question: is it also possible to open the cmd as administrator? entering cmd then CTRL-SHIFT-ENTER doesn't seem to work. – LPChip Jul 29 '15 at 12:24
  • 1
    @LPChip I don't think so. It opens command as the current user ... :/ – DavidPostill Jul 29 '15 at 12:36
  • 2
    @LPChip Workaround: [How to Add an "Open Command Prompt Here As Administrator" Shortcut to the Context Menu in Windows 7 and Windows Vista](http://www.wikihow.com/Add-an-%22Open-Command-Prompt-Here-As-Administrator%22-Shortcut-to-the-Context-Menu-in-Windows-7-and-Windows-Vista) – DavidPostill Jul 29 '15 at 12:43
  • 2
    @DavidPostill, How about enabling "run this program as an administrator" for c:\windows\system32\cmd.exe ? I could confirm it but I don't want to try this on my work computer right now :D – clhy Jul 29 '15 at 12:52
  • @The_IT_Guy_You_Don't_Like - I can't test it either. I don't have a non admin account here. – DavidPostill Jul 29 '15 at 12:53
16

Hold down shift while right-clicking anywhere in the folder. You will be presented with an option to "Open Command Window Here".

You can also shift + right click on any sub folder and open a command window there as well.

Alec Gorge
  • 413
  • 1
  • 4
  • 17
12

If you're a GUI kind of person, holding Shift during right-click makes "Open command window here" appear in the context menu. You can try it on current or nested folders.

insider
  • 121
  • 3
10

I use the ContextConsole Shell Extension. When you make a right click you get an option to run a command prompt and run a command prompt as admin (elevated) to do system tasks.

enter image description here

magicandre1981
  • 97,301
  • 30
  • 179
  • 245
4

If you don't mind using third-party extensions, the free ClassicShell allows adding a custom toolbar to Windows Explorer.

Example of custom toolbar

The image shows the configuration that I currently use. The button on the far right opens a console window to the current folder. This is how you can get it.

  • Install the Classic Explorer part of ClassicShell
  • Open a new Explorer window. You should now see an additional toolbar right below the address bar.
  • Right-Click into the toolbar and select 'Classic Explorer Settings'
  • In the opening dialog window, check the 'Show all settings' checkbox.
  • Go to the 'Toolbar Buttons' tab to configure the layout of the custom toolbar. Feel free to throw out any buttons that you don't like.
  • Add a 'Custom' button from the list on the right. Double-click the newly added button in the list on the left and enter cmd in the 'Command' field.

I am usually not a big fan of third-party extensions, but I found this one to be very useful, especially for this particular use case.

ComicSansMS
  • 364
  • 2
  • 10
3

While at the explorer, in the bar at the top there is a file menu where you have the option to open the command window for the current directory. This work in Windows 8. (In Windows 7 hold down the shift key when you click the File menu).

Salman A
  • 1,652
  • 2
  • 19
  • 32
Ed_
  • 211
  • 1
  • 6
0

Note that - if you want a static icon on the desktop that opens the CMD prompt at a certain folder location - you can also do the following:

  1. Create a shortcut on the desktop to CMD.EXE
  2. Right-click the shortcut and go into Properties
  3. On the Shortcut tab, put your desired location in the "Start In" field.

Obviously, this only works from the icon and always opens the same location. The other answers are a better way of opening the prompt to whatever your current folder is (dynamically).

Omegacron
  • 395
  • 1
  • 2
  • 9