Right-Click Open to File/Folder Command Prompt

Disclaimer: As with any registry action, please make sure you perform a full registry backup first! You are entirely responsible for modifying your registry and by using this registry mod, you agree to hold me, WordPress, affiliates and everyone else completely harmless of anything and everything that happens! In general, you should not download .reg files. If you do, thoroughly review every line (notepad) before running it! As with any site, I encourage you to read each line of this registry mod before running it!

Open Folder in CMDI often find myself browsing some file or folder location in Windows Explorer and find that I need to run something from the command-line (e.g. batch file, command-line utility, etc.). However, the command prompt opens to the current user’s profile folder (e.g. C:\Users\%userprofile%) by default. This is generally far from where I need to be. So I end up having to change directories all the way to the path I was browsing, hoping I remember the entire path.

To make things easier I made a little registry mod that adds an “Open Folder in CMD” option to the right-click menu for folders, files and the desktop. After running the mod, all you have to do is right-click any folder, file or the desktop and select “Open Folder in CMD”. It will then open the command prompt directly to the folder you just right-clicked on! It saves a ton of time and hassle trying to get back into the same folder. Here is what it looks like from the Desktop (at left).

You can use this mod anywhere Windows Explorer exists. Some examples are inside of a File Open or Close Dialog, from auto-search results in the Run box, etc. Below is an example of running it from within Windows Explorer itself. If you click a file, it opens the folder containing that file.

To install this registry modification, simply do the following.

Open Folder in CMD
Open folder in CMD from Folder
  1. Download the file from here.
  2. Open Notepad.
  3. Click File -> Open.
  4. Browse to where you stored the file and click Open.
  5. Review the contents to be sure you’re comfortable with it.
  6. Close Notepad.
  7. Rename the end of the file from .xlsx (Excel) to .reg (Registry Import/Export).
    1. This is required because most modern browsers, antivirus, etc. will not allow download of registry files. So, we had to trick it. If it still won’t download, please leave a comment and I might just have to post the text in this post so you can copy & paste it into your own .reg file.
  8. Double-click the .reg file.

That’s it! You’re all done. It takes effect immediately, without you having to restart Windows. I’ve tried this on Windows 7 and it works great. It should work on others as well, but not sure how far back it’ll work (2000, XP, etc.). If you find out, please let me know in the comments section!

I hope this helps save you time, as it does for me!

8 thoughts on “Right-Click Open to File/Folder Command Prompt

  1. Wow, amazing work, except it gives you the one folder up.

    For example, if I create Folder1 on my C drive, then go into it and create Folder2, right clicking the Folder2 and choosing the Open in CMD option, it opens Command Prompt at C:\Folder1. I have to go into Folder2 then click an empty space and Open in CMD to be at C:\Folder1\Folder2.

    Any regmod you have that can change this?

    1. Gavin,

      Yea, unfortunately the %1 parameter only gives the folder you’re currently in. Therefore selecting this on a highlighted folder opens the folder that contains the highlighted folder. I don’t see a way of doing the one you’ve selected (but I’ll keep my eyes open). However, as a work around, you could open that folder and right-click it from the left hand column in Windows Explorer or right-click an item inside of that folder. I hope that works for you!


    2. Thanks Gavin! Yea, for my needs I wanted to use this to be able to execute batch files from the command line and remain at the command prompt after it completed.

      Therefore I wanted the parent folder of the file I was selecting. If you want to have the current folder, you can instead select a file inside the folder first or you could try modifying the %1 value to the below text.

      cmd.exe /k pushd %L

      I’m not sure if it will work, but it’s worth a try. As usual when working with the registry, please take the precautions I noted in my article (backup registry first).

      I hope this helps!

  2. For me all folders from all drives open in C:\Windows\system32>. it you make a simple Google search with “right click command prompt” you will find lots of reg files.

    1. Interesting. What version of Windows are you using? It’s worked for others, so I’m assuming either some unintentional text got in there or you’re using a version of Windows that I wasn’t able to test with.

      Let me know if something else helps instead and what version of Windows please. Thanks!

    1. Mentors, sorry I wasn’t able to reply immediately. Did you change the script at all before executing it? What version of windows are you opening it on? Are you right-clicking shortcuts or the files themselves? Anyway, thanks for letting me know about the other scripts. I could have done something in PowerShell, but when I needed this I just needed something quick. Thanks for your readership.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s