How to open Windows CMD so that it starts in the current folder?

85

20

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.

boleslaw.smialy

Posted 2015-07-29T12:10:05.340

Reputation: 881

Question was closed 2015-08-01T00:04:51.943

@Dave : the solutions from this topic do not work on my station. – boleslaw.smialy – 2015-07-29T12:24:46.413

@Dave : ok, I got it. I will adjust next time. – boleslaw.smialy – 2015-07-29T12:33:25.803

1Note 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 – 2015-07-29T17:49:58.917

Shift-right click would let you open cmd in current directory. – Derek 朕會功夫 – 2015-07-30T02:14:08.420

All these solutions give a normal cmd. Are there any solutions for an elevated prompt? – Nzall – 2015-07-30T15:27:49.203

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.

– Salman A – 2015-07-31T08:44:58.380

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 – 2015-08-04T23:32:13.650

Answers

134

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

Posted 2015-07-29T12:10:05.340

Reputation: 1 664

9Not sure why anyone would use the 'cmd' option over this. – Matthew – 2015-07-29T16:59:08.157

@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 – 2015-07-29T17:03:16.977

3cmd 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 – 2015-07-29T18:33:02.643

11@sunk818 You can get the current folder also if you right click not on a folder. – Seiyria – 2015-07-29T18:54:03.953

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 – 2015-07-30T00:27:15.990

@jpmc26 : this solution does not work for me, that's why I've opened this topic. – boleslaw.smialy – 2015-07-30T06:29:35.037

@Seiyria This option doesn't appear in a library folder (as opposed to a real directory), unfortunately. There is a way to add it.

– Bob – 2015-07-30T07:07:22.313

@Bob I bet that's why it sometimes wasn't there. Thanks for letting me know. – Seiyria – 2015-07-30T12:17:00.013

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 – 2015-07-30T12:54:29.687

@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 – 2015-07-30T16:44:32.210

+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 – 2015-07-30T21:48:48.363

@MiniRagnarok : I have no idea why that solution does not work for me. i have Win7 and local adm privileges. – boleslaw.smialy – 2015-07-31T06:23:08.940

@boleslaw.smialy What edition of Windows? If you type cmd into the search bar does the command line window come up? – MiniRagnarok – 2015-07-31T14:41:43.417

1Broken in Win 10, right? – obiwahn – 2015-08-15T15:45:43.340

@obiwahn No, it works just fine. – Seiyria – 2015-08-16T02:54:00.497

Oh, indeed. I had to deactivate StrokesPlus to make it work. – obiwahn – 2015-08-16T08:22:20.167

@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 – 2016-11-11T08:56:18.027

232

Enter cmd in explorer's address bar & press enter

enter image description here

pun

Posted 2015-07-29T12:10:05.340

Reputation: 5 311

33OMG, I can't believe that actually works! +1 for both answers. :) – LPChip – 2015-07-29T12:22:34.780

4Even better is that it works for other programs too! – afrazier – 2015-07-29T17:31:43.730

1thanks 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 – 2015-07-29T23:37:01.913

11also, for efficiency, ALT+D ,"cmd" , ENTER – Some_Guy – 2015-07-30T12:54:37.910

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 – 2015-07-30T15:38:59.753

3That's because you can't cd to a network drive unless it is mapped to a drive letter – Borodin – 2015-07-30T18:24:44.893

@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 – pun – 2015-07-30T19:53:44.993

@Some_Guy : Alt+D is the reason why i've asked this questions: it does simply not work on my station :) – boleslaw.smialy – 2015-08-12T06:49:08.653

@boleslaw.smialy are you pressing Alt then D or Alt + D ? – pun – 2015-08-12T06:58:50.960

This still works in Windows 10 (unlike the SHIFT key answer). – obiwahn – 2015-08-15T15:46:11.920

@Some_Guy even more efficient, Shift+Menu, W (might be different on other languages) – phuclv – 2016-11-11T08:57:07.770

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

Posted 2015-07-29T12:10:05.340

Reputation: 118 938

1followup question: is it also possible to open the cmd as administrator? entering cmd then CTRL-SHIFT-ENTER doesn't seem to work. – LPChip – 2015-07-29T12:24:04.463

1@LPChip I don't think so. It opens command as the current user ... :/ – DavidPostill – 2015-07-29T12:36:40.180

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 – pun – 2015-07-29T12:52:01.273

@The_IT_Guy_You_Don't_Like - I can't test it either. I don't have a non admin account here. – DavidPostill – 2015-07-29T12:53:44.717

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

Posted 2015-07-29T12:10:05.340

Reputation: 413

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

Posted 2015-07-29T12:10:05.340

Reputation: 121

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

Posted 2015-07-29T12:10:05.340

Reputation: 86 560

It is interesting solution, but for most corporate people it would be useless because of lack of Adm privilages. – boleslaw.smialy – 2015-07-30T10:19:14.257

yes, but I have the permissions and use it very often to runs scripts that require elevation. Here this extension is used very often. – magicandre1981 – 2015-07-30T15:57:40.830

Will this work with right clicking on empty space too (e.g. Desktop) or only when clicking on folder items in Explorer? – Samir – 2015-07-30T23:20:45.577

@sammyg this will work only for clicking on en empty entry. – magicandre1981 – 2015-07-31T04:19:14.447

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

Posted 2015-07-29T12:10:05.340

Reputation: 292

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).

Weapon X

Posted 2015-07-29T12:10:05.340

Reputation: 171

Yes, that works for windows 8 and 8.1, but the O.P. asked specifically for windows 7. – Ismael Miguel – 2015-07-31T09:34:08.857

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

Posted 2015-07-29T12:10:05.340

Reputation: 365