Windows 11 右鍵選單加入「Open in Claude Code」安裝手冊
前言
本手冊介紹兩種方式,在 Windows 11 的右鍵選單中加入 Open in Claude Code 選項,讓你可以快速在任意資料夾啟動 Claude Code CLI。
- 方案 A(推薦):透過 Custom Context Menu 應用程式,項目會出現在 Windows 11 新式右鍵選單中。
- 方案 B:透過 Windows Registry(
.reg登錄檔),項目會出現在舊式右鍵選單(需點擊「顯示更多選項」或Shift + 右鍵)。
前提條件
- Windows 11
- Claude Code CLI 已安裝且
claude指令在 PATH 中可用 - Claude Code 執行檔路徑:
%USERPROFILE%\.local\bin\claude.exe
方案 A:Custom Context Menu(新式右鍵選單)
由於 Windows 11 的新式右鍵選單無法透過純 Registry 方式新增自訂項目,需要使用第三方應用程式 ContextMenuForWindows11(開源,LGPL-3.0 授權)。
Step 1:安裝 Custom Context Menu
方式一:Microsoft Store(付費,約 $1 USD)
在 Microsoft Store 搜尋 Custom Context Menu 直接安裝。付費是支持開發者,功能與免費版完全相同。
方式二:GitHub Release(免費)
-
前往 Releases 頁面,下載 ContextMenuCustom-CMC_GITHUB_RELEASE-x64.zip(x64 架構)。
-
解壓縮後,目錄結構如下:
ContextMenuCustomGithubPackage_x.x.x.xx_Test/├── ContextMenuCustomGithubPackage_x.x.x.xx_x64.cer ← 憑證├── ContextMenuCustomGithubPackage_x.x.x.xx_x64.msixbundle ← 安裝包└── Dependencies/└── x64/├── Microsoft.NET.Native.Framework.2.2.appx├── Microsoft.NET.Native.Runtime.2.2.appx├── Microsoft.UI.Xaml.2.8.appx├── Microsoft.VCLibs.x64.14.00.appx└── Microsoft.VCLibs.x64.14.00.Desktop.appx -
安裝憑證(以系統管理員身份開啟 PowerShell):
Import-Certificate -FilePath ".\ContextMenuCustomGithubPackage_x.x.x.xx_x64.cer" -CertStoreLocation Cert:\LocalMachine\Root注意: 憑證必須安裝在
Cert:\LocalMachine\Root(受信任的根憑證授權單位),安裝在Trusted People或CurrentUser會導致後續安裝 msixbundle 時報錯0x800B0109。 -
安裝應用程式:
Add-AppPackage -Path ".\ContextMenuCustomGithubPackage_x.x.x.xx_x64.msixbundle"Dependencies 會自動安裝。
Step 2:新增 Open in Claude Code 選單項目
方式一:透過 App GUI
-
開啟 Custom Context Menu(在開始選單搜尋)。
-
點左側的 + 新增選單項目。
-
填入以下設定:
欄位 值 Title Open in Claude CodeExe cmd.exeParam /c cd /d "{path}" && claudeIcon %USERPROFILE%\.local\bin\claude.exeMatch Folder ✅ 開啟 Match File ❌ 關閉 -
點 Save 儲存。
方式二:直接放 JSON 設定檔
-
在 App 中點左上角的資料夾圖示,打開設定目錄(路徑為
%LOCALAPPDATA%\Packages\{appId}\LocalState\custom_commands\)。 -
在該目錄建立
Open in Claude Code.json,內容如下:{"title": "Open in Claude Code","exe": "cmd.exe","param": "/c cd /d \"{path}\" && claude","icon": "%USERPROFILE%\\.local\\bin\\claude.exe","acceptExts": "","acceptDirectory": true,"acceptDirectoryFlag": 0,"acceptFile": false,"acceptMultipleFilesFlag": 0,"pathDelimiter": "","paramForMultipleFiles": "","index": 0}
Step 3:生效
- 如果 App 有開啟 Cache,點一下 Toggle Cache 重新整理。
- 在工作管理員中重啟 Windows Explorer,或登出再登入。
- 右鍵點擊資料夾,即可在新式選單中看到 Open in Claude Code。
備註: 選單項目會出現在 Custom Context Menu 的子選單底下,預設名稱為 "Custom Context Menu",可在 App 設定中修改 Root Entry 名稱。
方案 B:Registry 登錄檔(舊式右鍵選單)
此方式透過 .reg 檔案將選項寫入 Windows Registry,項目會出現在舊式右鍵選單中(點擊「顯示更多選項」或 Shift + 右鍵 可見)。
安裝
建立 add-claude-code-context-menu.reg,內容如下:
Windows Registry Editor Version 5.00
; --- Right-click on a FOLDER ---
[HKEY_CURRENT_USER\Software\Classes\Directory\shell\ClaudeCode]
@="Open in Claude Code"
"Icon"="%USERPROFILE%\\.local\\bin\\claude.exe"
[HKEY_CURRENT_USER\Software\Classes\Directory\shell\ClaudeCode\command]
@="cmd.exe /c cd /d \"%V\" && claude"
; --- Right-click on directory BACKGROUND (empty space inside a folder) ---
[HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\ClaudeCode]
@="Open in Claude Code"
"Icon"="%USERPROFILE%\\.local\\bin\\claude.exe"
[HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\ClaudeCode\command]
@="cmd.exe /c cd /d \"%V\" && claude"
雙擊 .reg 檔案,確認合併到登錄檔即可。涵蓋兩種情境:
- 右鍵點擊資料夾本身 → Open in Claude Code
- 在資料夾內空白處右鍵 → Open in Claude Code
不需要重開機,新開的 Explorer 視窗即生效。
移除
建立 remove-claude-code-context-menu.reg,內容如下:
Windows Registry Editor Version 5.00
[-HKEY_CURRENT_USER\Software\Classes\Directory\shell\ClaudeCode]
[-HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\ClaudeCode]
雙擊執行即可移除。
選擇性:停用新式選單,改用舊式選單
如果你希望右鍵直接顯示舊式完整選單(方案 B 的項目就會直接可見),可以執行以下指令:
reg add "HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32" /f /ve
重啟 Explorer 後生效。恢復新式選單:
reg delete "HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}" /f
方案比較
| 方案 A(Custom Context Menu) | 方案 B(Registry) | |
|---|---|---|
| 出現位置 | Windows 11 新式右鍵選單 | 舊式右鍵選單(顯示更多選項) |
| 安裝難度 | 需安裝第三方 App | 雙擊 .reg 檔即可 |
| 可自訂性 | 高(GUI 管理、JSON 設定) | 低(需手動編輯 Registry) |
| 移除方式 | App 內刪除或移除 JSON | 執行移除用 .reg 檔 |
| 依賴 | Custom Context Menu App | 無 |
兩種方案可以同時使用,不會衝突。