There are at least a couple of ways to open Command Prompt in the current folder path from a folder window. The two widely used options include running cmd.exe
from the File Explorer address bar and using the Open Command window here option from the folder background context menu.
But, no built-in option exists to accomplish this using a keyboard shortcut or hotkey. This post tells you how to open Command Prompt (or admin Command Prompt) in the current directory path using the AutoHotkey automation tool.
Open Command Prompt in Current Folder Using Keyboard Shortcut
Here is to open Command Prompt in the current folder by assigning a hotkey (Winkey + C) using AutoHotkey.
- Download AutoHotkey and install it.
- Open Notepad and copy the lines of code given below
- Save the file with .ahk extension — e.g.,
open_cmd_here.ahk
#c::opencmdhere() ; Press Win + C to open Command Prompt in the current directory. opencmdhere() { If WinActive("ahk_class CabinetWClass") || WinActive("ahk_class ExploreWClass") { WinHWND := WinActive() For win in ComObjCreate("Shell.Application").Windows If (win.HWND = WinHWND) { currdir := SubStr(win.LocationURL, 9) currdir := RegExReplace(currdir, "%20", " ") Break } } Run, cmd, % currdir ? currdir : "C:\" } #+c::opencmdhereadmin() ; Press Win + Shift + C to open admin Command Prompt in the current directory. opencmdhereadmin() { If WinActive("ahk_class CabinetWClass") || WinActive("ahk_class ExploreWClass") { WinHWND := WinActive() For win in ComObjCreate("Shell.Application").Windows If (win.HWND = WinHWND) { currdir := SubStr(win.LocationURL, 9) currdir := RegExReplace(currdir, "%20", " ") currdir := RegExReplace(currdir, "/", "\") Break } } Run *RunAs cmd.exe /k pushd %currdir% }
Credits: tmplinshi
- Double-click the .ahk file to run it.
The script runs in the background and shows up in the notification area.
- To open a Command Prompt window from the current folder, press Win + C
- To open admin Command Prompt from the current folder, press Win + Shift + C
It intercepts the Winkey + C as well as Win + Shift + C hotkeys, gets the current File Explorer folder path and opens a Command Prompt window in the current folder location.
Note: If no folder windows are currently open, or if a non-file system folder such as This PC, Libraries or Quick access is the current folder, then pressing Winkey + C will launch Command Prompt to C:\
If the script is always running in the background, does it occupy more memory?
No! The script is extremely light-weight, and it uses only 400 Kilobytes to 2.5 MB of system memory approximately.
Other ways to open Command Prompt in the current directory
In the address bar of File Explorer, type cmd.exe
and press ENTER
It launches Command Prompt in the current folder location. If a non-file system folder such as This PC or Quick access is the current folder, then running cmd.exe opens to C:\Windows\System32
by default.
Another option is to right-click an empty area in that folder and click Open command window here. If the option doesn’t appear, press the Shift key when right-clicking.
If Open command window here is still missing from the right-click menu, then apply the registry edit described in the article Get back “Open command window here” context menu option in Windows 10
One small request: If you liked this post, please share this?
One "tiny" share from you would seriously help a lot with the growth of this blog. Some great suggestions:- Pin it!
- Share it to your favorite blog + Facebook, Reddit
- Tweet it!