Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學

Windows 當前資料夾快速開啟命令提示字元:Shift+右鍵選單與 AutoHotkey 熱鍵兩大神技

編輯:XP 系統應用技巧

痛點:cd 指令切換路徑太繁瑣

在檔案總管中已瀏覽到目標資料夾,仍需開啟 CMD 再 cd /d 路徑,極度低效。Linux 右鍵「在終端機開啟」早成標配,Windows 也有原生與腳本兩種解法。

方法一:原生 Shift+右鍵 →「在此處開啟命令視窗」 (Win7/8/10/11)

  1. 在資料夾空白處或磁碟機根目錄,按住 Shift + 滑鼠右鍵。
  2. 選單中會出現「在此處開啟 PowerShell 視窗」或「在此處開啟命令提示字元」(Win10 1703 後預設 PowerShell)。
  3. 選取即在當前路徑開啟終端機。

進階:移除 Shift 鍵需求,直接右鍵即見選項 (登錄修改)

  1. regedit 依序展開:
  • HKEY_CLASSES_ROOT\Directory\shell\cmd
  • HKEY_CLASSES_ROOT\Drive\shell\cmd
  • HKEY_CLASSES_ROOT\Directory\Background\shell\cmd
  1. 在每個 cmd 鍵值下,刪除 Extended 字串值 (或重命名為 Extended_)。
  2. 即可直接右鍵看到選項,無需按 Shift。

⚠ 修改登錄前請匯出備份;系統更新可能重置此設定。

方法二:AutoHotkey 一鍵熱鍵開啟 (極客最愛)

安裝 AutoHotkey 後,建立腳本 open_cmd_here.ahk:

#IfWinActive ahk_class CabinetWClass || ahk_class ExploreWClass
; Win+E 開啟檔案總管時,按 Win+C 在當前路徑開啟 CMD
#c::
    OpenCmdInCurrent()
return

OpenCmdInCurrent() {
    ; 取得檔案總管地址列完整路徑
    ControlGetText, path, ToolbarWindow322, A
    if (path = "") {
        ControlGetText, path, ToolbarWindow323, A
    }
    ; 移除「檔案總管 >」前綴
    RegExMatch(path, "(.*)\\s*[>]]", path)
    Run, cmd.exe /k cd /d "%path%"
}
#IfWinActive
  • 雙擊腳本載入,之後在檔案總管按 Win+C 即可在當前資料夾開啟 CMD。
  • 可自訂熱鍵 (如 F4、Ctrl+T)。
  • 支援多標籤總管 (QTTabBar、ExplorerPatcher 等) 需微調控制項類別名。

補充:Windows Terminal / PowerShell 7+ 現代化替代

  • Win11 預設右鍵選單已整合「在終端機開啟」 (Windows Terminal)。
  • Win10 可安裝 Windows Terminal (Microsoft Store),設定為預設終端機。
  • PowerShell 7+ 跨平台、效能更佳、語法更強,建議逐步遷移。

結語

Shift+右鍵是零成本原生解法;AutoHotkey 則提供極致客製化熱鍵體驗。依習慣選擇,告別手動 cd,讓命令列真正融入檔案操作流程。

Copyright © Windows教程網 All Rights Reserved