Open Command or Powershell Window From Explorer

Open Command or Powershell Window From Explorer

Command line tools are becoming increasingly popular, so this tip may save you some time. On Windows, there are several ways to open up a command window. My typical method is to just hit the Start key and type ‘cmd’ and then enter. This will open a window in my user folder, which is exactly where I want to be precisely 0% of the time. From there, it’s usually just a few dozen command to change folders and drives to get to where I actually need to be.

Fortunately, there’s a (much) easier way. Most of the time, I either already have a Windows Explorer/File Explorer window open for the folder I’m working with, or I can quickly get one (my go-to tools Visual Studio and SourceTree both have quick menu options to open folder in explorer). From there, it’s simple to get either a command window or a powershell window (and probably bash, but I haven’t gone there, yet). Just click in the whitespace of the path as shown below, and type ‘cmd’ (or ‘powershell’). You’ll see a new instance of the appropriate window created, and lo and behold, it in the path from which you launched it!

explorer-shortcut

 

You can also shift-rightclick in a folder to choose “open command window here” but I find that to be slower and less intuitive than this approach (and it doesn’t have a powershell option).

Another handy tip for command/powershell windows is alt-enter to toggle fullscreen. Especially handy for presenting or when you know you’re going to be spending some time there.

If you have any related tips, please share them in the comments below.

  • Great tip! I copy-paste a path from Explorer into a new PowerShell console multiple times a day, but this is much cleaner!

  • Michal

    Thanks for the tip. There is also an option to open command line from the context menu (right click some where in the window) while hoding the Shift button.

    • ardalis

      Yep, I mention that in my article. But I can never remember if it’s Shift, Alt, Ctrl or what to get that, so it’s usually just quicker to type ‘cmd’ for me (also less mousing around).

  • A_Franklin

    If you’re using Windows 10, the File menu of Windows Explorer builds this right in! Just click File > Open Command Prompt, or click File > Open Windows PowerShell and it’ll start a prompt at the current folder location (those options may be grayed out if the current location is not a path your CLI would recognize).

    https://uploads.disquscdn.com/images/e90b786bc517114f45fb1c47e73f40f55e6f4eb2a12b3fc9f374bb3ad36ac4a6.png

    • ardalis

      Nice, thanks for sharing!

  • Brian

    Good tip Steve. Thanks for sharing. I had no idea you could do that. I’ll add that in Explorer you can use the ALT + D keyboard shortcut to modify the address field if you don’t want to click in the whitespace up there. Pretty efficient!

    • ardalis

      Cool, thanks. Wasn’t aware of that shortcut.

      • Brian

        Sure thing. ALT + D works in browsers (IE, Edge, Chrome) too… most places where there is and aDdress field.

        • ardalis

          Ah, I usually F6 for that in browsers. (goes and checks) Which apparently doesn’t do the same thing in Windows/File Explorer…

          Another key sequence for you can use for the above is Alt – F – P for command Prompt or Alt – F – R for powerRshell. Hit each key individually, don’t hold down alt. Does the same thing A_Franklin notes below, but without having to use the mouse.