10

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?

1
  • any reason for downvote?
    – Louis Rhys
    Apr 9 '13 at 16:20
14
  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.

4
  • +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
    Apr 8 '13 at 16:24
  • @LouisRhys: See my edited answer above.
    – Karan
    Apr 8 '13 at 16:48
  • 1
    that's cool! Do you happen to know if it's possible to rearrange the position of the menu too?
    – Louis Rhys
    Apr 9 '13 at 1:42
  • 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
    Apr 9 '13 at 11:48
18

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.

2
  • 1
    +1 that's nice. Makes me wonder why it only appears with Shift
    – Louis Rhys
    Apr 8 '13 at 11:52
  • 4
    @LouisRhys: Because it has the Extended verb set. See my answer to know how to disable the verb.
    – Karan
    Apr 8 '13 at 12:39
9

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

9
  • 2
    This fails completely to answer OP's question. Could you at least take some time to clarify your answer and explain your reasoning? Oct 23 '13 at 5:22
  • 6
    Have 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
    Oct 23 '13 at 9:36
  • 2
    Did 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. Oct 24 '13 at 3:00
  • 7
    Not 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
    Oct 24 '13 at 10:21
  • 1
    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
    Mar 19 '14 at 20:36
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

3
  • 1
    In English versions, the shortcut would be Alt, F, P
    – w32sh
    Jul 9 '16 at 10:04
  • @w32sh That open a properties dialog for me on Windows 7, which is what the question is tagged.
    – DavidPostill
    Jul 10 '16 at 11:04
  • My mistake. Thought I was in Windows 10 topic area.
    – w32sh
    Jul 10 '16 at 11:37
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.

0

If you want as shown in the image enter image description here

  1. make sure new windows terminal is installed from windows store
  2. make sure git bash is installed (if you don't need remove its code)
  3. download terminal ico file and place in "C:\ProgramData"
  4. copy/paste reg code to text file change extension to .reg
  5. replace username with your username and save file
  6. double click on the file and click yes, yes
  7. open terminal settings and configure as you like

https://github.com/microsoft/terminal/blob/main/res/terminal.ico

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\WindowsTerminal]
@=""
"Icon"="C:\\ProgramData\\terminal.ico"
"ExtendedSubCommandsKey"="Directory\\ContextMenus\\WindowsTerminal"
"MUIVerb"="Windows Terminal"

[HKEY_CLASSES_ROOT\Directory\ContextMenus\WindowsTerminal]
[HKEY_CLASSES_ROOT\Directory\ContextMenus\WindowsTerminal\shell]

; ________ GIT BASH ________
[HKEY_CLASSES_ROOT\Directory\ContextMenus\WindowsTerminal\shell\bash]
"MUIVerb"="bash"
"Icon"="C:\\Program Files\\Git\\mingw64\\share\\git\\git-for-windows.ico"
[HKEY_CLASSES_ROOT\Directory\ContextMenus\WindowsTerminal\shell\bash\command]
@="C:\\Users\\username\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe new-tab -p bash -d ."

; ________ CMD ________
[HKEY_CLASSES_ROOT\Directory\ContextMenus\WindowsTerminal\shell\cmd]
"MUIVerb"="cmd"
"Icon"="cmd.exe"
[HKEY_CLASSES_ROOT\Directory\ContextMenus\WindowsTerminal\shell\cmd\command]
@="C:\\Users\\username\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe new-tab -p cmd -d ."

; ________ POWER SHELL ________
[HKEY_CLASSES_ROOT\Directory\ContextMenus\WindowsTerminal\shell\pwsh]
"MUIVerb"="powershell"
"Icon"="powershell.exe"
[HKEY_CLASSES_ROOT\Directory\ContextMenus\WindowsTerminal\shell\pwsh\command]
@="C:\\Users\\username\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe new-tab -p powershell -d ."

The new windows terminal's settings should look like this

"profiles":
    {
        "defaults":
        {
            // Put settings here that you want to apply to all profiles.
            "startingDirectory": "%userprofile%",
            "fontSize" : 10,
            "useAcrylic": true,
            "acrylicOpacity": 0.9
        },
        "list":
        [
            {
                "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
                "name": "cmd",
                "commandline": "cmd.exe",
                "hidden": false
            },
            {
                "guid": "{00000000-0000-0000-ba88-000000000002}",
                "closeOnExit" : "always",
                "commandline" : "\"%PROGRAMFILES%\\git\\usr\\bin\\bash.exe\" -i -l",
                "icon" : "C:\\Program Files\\Git\\mingw64\\share\\git\\git-for-windows.ico",
                "name" : "bash",
                "background": "#141f25"
            },
            {
                "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
                "name": "powershell",
                "commandline": "powershell.exe",
                "hidden": false,
                "background": "#2d3f70"
            }
        ]
    },
-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!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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