{"id":9842,"date":"2019-06-19T08:31:52","date_gmt":"2019-06-19T08:31:52","guid":{"rendered":"http:\/\/198.58.113.91\/blog\/?p=9842"},"modified":"2019-06-27T10:27:05","modified_gmt":"2019-06-27T10:27:05","slug":"open-command-prompt-current-folder-keyboard-shortcut","status":"publish","type":"post","link":"https:\/\/www.winhelponline.com\/blog\/open-command-prompt-current-folder-keyboard-shortcut\/","title":{"rendered":"Open Command Prompt in Current Folder Using Keyboard Shortcut"},"content":{"rendered":"<p>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 <code>cmd.exe<\/code> from the File Explorer address bar and using the <a href=\"https:\/\/www.winhelponline.com\/blog\/cmd-here-windows-10-context-menu-add\/\">Open Command window here<\/a> option from the folder background context menu.<\/p>\n<p>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 <a href=\"https:\/\/www.winhelponline.com\/blog\/open-elevated-command-prompt-windows\/\">admin Command Prompt<\/a>) in the current directory path using the AutoHotkey automation tool.<!--more--><\/p>\n<h2>Open Command Prompt in Current Folder Using Keyboard Shortcut<\/h2>\n<p>Here is to open Command Prompt in the current folder by assigning a hotkey (<kbd>Winkey<\/kbd> + <kbd>C<\/kbd>) using AutoHotkey.<\/p>\n<ol>\n<li>Download <a href=\"https:\/\/www.autohotkey.com\/\" target=\"_blank\" rel=\"noopener nofollow noreferrer\">AutoHotkey<\/a> and install it.<\/li>\n<li>Open Notepad and copy the lines of code given below<\/li>\n<li>Save the file with .ahk extension &#8212; e.g., <code>open_cmd_here.ahk<\/code>\n<pre>#c::opencmdhere()\r\n; Press <strong>Win + C<\/strong> to open Command Prompt in the current directory.\r\n\r\nopencmdhere() {\r\n    If WinActive(\"ahk_class CabinetWClass\") || WinActive(\"ahk_class ExploreWClass\") {\r\n        WinHWND := WinActive()\r\n        For win in ComObjCreate(\"Shell.Application\").Windows\r\n            If (win.HWND = WinHWND) {\r\n\t\tcurrdir := SubStr(win.LocationURL, 9)\r\n\t\tcurrdir := RegExReplace(currdir, \"%20\", \" \")\r\n                Break\r\n            }\r\n    }\r\n    Run, cmd, % currdir ? currdir : \"C:\\\"\r\n}\r\n\r\n#+c::opencmdhereadmin()\r\n; Press <strong>Win + Shift + C<\/strong> to open <strong>admin Command Prompt<\/strong> in the current directory.\r\n\r\nopencmdhereadmin() {\r\n    If WinActive(\"ahk_class CabinetWClass\") || WinActive(\"ahk_class ExploreWClass\") {\r\n        WinHWND := WinActive()\r\n        For win in ComObjCreate(\"Shell.Application\").Windows\r\n            If (win.HWND = WinHWND) {\r\n\t\tcurrdir := SubStr(win.LocationURL, 9)\r\n\t\tcurrdir := RegExReplace(currdir, \"%20\", \" \")\r\n\t\tcurrdir := RegExReplace(currdir, \"\/\", \"\\\")\r\n                Break\r\n            }\r\n    }\r\n\r\n    Run *RunAs cmd.exe \/k pushd %currdir%\r\n}\r\n<\/pre>\n<p><em>Credits: <a href=\"https:\/\/www.autohotkey.com\/boards\/viewtopic.php?t=5796\" target=\"_blank\" rel=\"noopener nofollow noreferrer\">tmplinshi<\/a><\/em><\/li>\n<li>Double-click the .ahk file to run it.<\/li>\n<\/ol>\n<p>The script runs in the background and shows up in the notification area.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-9843 alignnone\" src=\"https:\/\/www.winhelponline.com\/blog\/wp-content\/uploads\/2019\/06\/open-cmd-here-autohotkey-1.png\" alt=\"open command prompt in current folder - autohotkey\" width=\"220\" height=\"124\" \/><\/p>\n<ul>\n<li>To open a Command Prompt window from the current folder, press <kbd>Win<\/kbd> + <kbd>C<\/kbd><\/li>\n<li>To open <strong>admin Command Prompt<\/strong> from the current folder, press <kbd>Win<\/kbd> + <kbd>Shift<\/kbd> + <kbd>C<\/kbd><\/li>\n<\/ul>\n<p>It intercepts the <kbd>Winkey<\/kbd> + <kbd>C<\/kbd> as well as <kbd>Win<\/kbd> + <kbd>Shift<\/kbd> + <kbd>C\u00a0<\/kbd>hotkeys, gets the current File Explorer folder path and opens a Command Prompt window in the current folder location.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9845\" src=\"https:\/\/www.winhelponline.com\/blog\/wp-content\/uploads\/2019\/06\/open-cmd-here-autohotkey-3.png\" alt=\"open command prompt in current folder - autohotkey\" width=\"700\" height=\"207\" \/><\/p>\n<p><strong>Note:<\/strong> 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 <kbd>Winkey<\/kbd> + <kbd>C<\/kbd> will launch Command Prompt to <code>C:\\<\/code><\/p>\n<p><em>If the script is always running in the background, does it occupy more memory?<\/em><\/p>\n<p>No! The script is extremely light-weight, and it uses only 400 Kilobytes to 2.5 MB of system memory approximately.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9844\" src=\"https:\/\/www.winhelponline.com\/blog\/wp-content\/uploads\/2019\/06\/open-cmd-here-autohotkey-2.png\" alt=\"open command prompt in current folder - autohotkey\" width=\"666\" height=\"101\" \/><\/p>\n<h2>Other ways to open Command Prompt in the current directory<\/h2>\n<p>In the address bar of File Explorer, type <code>cmd.exe<\/code> and press <kbd>ENTER<\/kbd><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9846\" src=\"https:\/\/www.winhelponline.com\/blog\/wp-content\/uploads\/2019\/06\/open-cmd-here-method-2.png\" alt=\"open command prompt in current folder - address bar cmd.exe\" width=\"300\" height=\"139\" \/><\/p>\n<p>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 <code>C:\\Windows\\System32<\/code> by default.<\/p>\n<p>Another option is to right-click an empty area in that folder and click <strong>Open command window here<\/strong>. If the option doesn&#8217;t appear, press the <kbd>Shift<\/kbd> key when right-clicking.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9847\" src=\"https:\/\/www.winhelponline.com\/blog\/wp-content\/uploads\/2019\/06\/open-cmd-here-method-3.png\" alt=\"open command prompt in current folder - context menu cmdhere\" width=\"295\" height=\"403\" \/><\/p>\n<p>If <strong>Open command window here<\/strong> is still missing from the right-click menu, then apply the registry edit described in the article <a href=\"https:\/\/www.winhelponline.com\/blog\/cmd-here-windows-10-context-menu-add\/\">Get back &#8220;Open command window here&#8221; context menu option in Windows 10<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 &#8230; <a title=\"Open Command Prompt in Current Folder Using Keyboard Shortcut\" class=\"read-more\" href=\"https:\/\/www.winhelponline.com\/blog\/open-command-prompt-current-folder-keyboard-shortcut\/\" aria-label=\"Read more about Open Command Prompt in Current Folder Using Keyboard Shortcut\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[7],"tags":[762,106],"class_list":["post-9842","post","type-post","status-publish","format-standard","hentry","category-windows","tag-autohotkey","tag-command-prompt"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":18617,"url":"https:\/\/www.winhelponline.com\/blog\/open-file-folder-path-clipboard-using-shortcut\/","url_meta":{"origin":9842,"position":0},"title":"How to Open File or Folder Path from the Clipboard Using Shortcut","author":"Ramesh","date":"September 15, 2020","format":false,"excerpt":"Sometimes we may need to copy a file or folder path from your email or chat window to the clipboard, and open the file or folder manually. Most people open the file or folder by launching the Run dialog, pasting the path from the Clipboard, and clicking OK. If your\u2026","rel":"","context":"In &quot;Utilities&quot;","block_context":{"text":"Utilities","link":"https:\/\/www.winhelponline.com\/blog\/category\/utilities\/"},"img":{"alt_text":"copy path to clipboard to Run dialog","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2020\/09\/copy-path-clipboard-run-dialog.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":8806,"url":"https:\/\/www.winhelponline.com\/blog\/turn-off-monitor-shortcut-command-windows\/","url_meta":{"origin":9842,"position":1},"title":"Turn Off Monitor Using Shortcut or Command-line in Windows","author":"Ramesh","date":"April 23, 2019","format":false,"excerpt":"My new Samsung Curved monitor has the power button on the rear end, perhaps for aesthetic purposes. I have been using monitors that have controls on the front or underneath the bezel all these years. Now, with the new monitor, I find it a little bit inconvenient to reach out\u2026","rel":"","context":"In &quot;Utilities&quot;","block_context":{"text":"Utilities","link":"https:\/\/www.winhelponline.com\/blog\/category\/utilities\/"},"img":{"alt_text":"controlmymonitor turn off primary monitor using desktop shortcut","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2019\/04\/controlmymonitor.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2019\/04\/controlmymonitor.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2019\/04\/controlmymonitor.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":3178,"url":"https:\/\/www.winhelponline.com\/blog\/winkey-e-shortcut-target-change\/","url_meta":{"origin":9842,"position":2},"title":"How to Change Win + E Shortcut Target in Windows 10\/11","author":"Ramesh","date":"June 1, 2016","format":false,"excerpt":"The WinKey + E keystroke, as well as the File Explorer shortcut on the taskbar, open Quick access view by default. You can change the default folder to This PC using Folder Options General tab, or make it open to the Downloads\u00a0folder using a registry method. But, how to make\u2026","rel":"","context":"In &quot;Windows 10&quot;","block_context":{"text":"Windows 10","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/windows-10\/"},"img":{"alt_text":"File Explorer shortcut","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2016\/06\/winkey-e-2.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":1237,"url":"https:\/\/www.winhelponline.com\/blog\/restore-new-folder-entry-shellnew-windows-7\/","url_meta":{"origin":9842,"position":3},"title":"Restore Missing New &#8220;Folder&#8221; to the Desktop Right-Click menu","author":"Ramesh","date":"July 7, 2013","format":false,"excerpt":"When you right-click an empty area on the desktop, the \"New\" menu that appears may not contain the \"Folder\" entry. Also, when attempting to create a folder by clicking the \"New Folder\" toolbar button in a folder or by pressing the Ctrl + Shift + N keys, nothing may happen.\u2026","rel":"","context":"In &quot;Windows&quot;","block_context":{"text":"Windows","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/"},"img":{"alt_text":"new folder creates new shortcut","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2013\/07\/new-folder-opens-shortcut-dialog.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2013\/07\/new-folder-opens-shortcut-dialog.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2013\/07\/new-folder-opens-shortcut-dialog.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":29797,"url":"https:\/\/www.winhelponline.com\/blog\/hotkey-show-hide-navigation-bar-explorer\/","url_meta":{"origin":9842,"position":4},"title":"Hotkey to Show\/Hide Navigation Bar in File Explorer","author":"Ramesh","date":"November 13, 2022","format":false,"excerpt":"The File Explorer in Windows 10 includes the keyboard shortcuts to enable or disable the Preview pane and the Details pane. However, there is no such shortcut available to toggle the navigation pane. So let's see how to overcome this limitation using AutoHotKey. Hotkey to Show\/Hide Navigation Bar in File\u2026","rel":"","context":"In &quot;Windows 10&quot;","block_context":{"text":"Windows 10","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/windows-10\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1520,"url":"https:\/\/www.winhelponline.com\/blog\/open-elevated-command-prompt-windows\/","url_meta":{"origin":9842,"position":5},"title":"How to Open Elevated or Admin Command Prompt in Windows?","author":"Ramesh","date":"March 5, 2007","format":false,"excerpt":"Command Prompt is one of the most used tools in Windows. For tasks requiring administrator privileges, we need to start Command Prompt as administrator (\"elevated\"). This article describes different ways to open an elevated or administrator Command Prompt window. How to Open Elevated or Admin Command Prompt From the Win-X\u2026","rel":"","context":"In &quot;Windows&quot;","block_context":{"text":"Windows","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/"},"img":{"alt_text":"task manager -run command prompt elevated - create new task","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2007\/03\/taskmgr-cmd-elevated.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2007\/03\/taskmgr-cmd-elevated.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2007\/03\/taskmgr-cmd-elevated.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2007\/03\/taskmgr-cmd-elevated.png?resize=700%2C400&ssl=1 2x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/posts\/9842","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/comments?post=9842"}],"version-history":[{"count":0,"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/posts\/9842\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/media?parent=9842"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/categories?post=9842"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/tags?post=9842"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}