![](/img/trans.png)
[英]How can I fix ? Remote - WSL will not open on VSCode - Error says `Multi distro not supported'
[英]How to open VSCode Remote-WSL by right click
我想通過在 Windows 文件資源管理器中右鍵單擊來打開 VSCode Remote-WSL 上的當前文件夾。 我怎樣才能做到? 先感謝您。
要為目錄添加 Windows 上下文菜單以在遠程 WSL 中的 Visual Studio Code 中打開它,請將這些 Windows 注冊表項添加為管理員:
reg add "HKEY_CLASSES_ROOT\Directory\shell\WSLVSCode\command" /t REG_EXPAND_SZ /d "wsl.exe code `wslpath '%1'`"
reg add "HKEY_CLASSES_ROOT\Directory\shell\WSLVSCode" /t REG_EXPAND_SZ /d "Open in WSL VSCode"
reg add "HKEY_CLASSES_ROOT\Directory\shell\WSLVSCode" /v Icon /t REG_EXPAND_SZ /d "C:\Users\User\AppData\Local\Programs\Microsoft VS Code\Code.exe"
更新圖標文件的正確路徑。
試試這個“在 WSL 中打開文件夾”:
制作一個注冊表文件(.reg),粘貼代碼並運行:
Windows 注冊表編輯器 5.00 版
; 刪除舊條目 [-HKEY_CLASSES_ROOT\\Directory\\shell\\VSCode] [-HKEY_CLASSES_ROOT\\Directory\\Background\\shell\\VSCode]
; 添加右鍵單擊文件夾的子菜單 [HKEY_CLASSES_ROOT\\Directory\\shell\\VSCode] "MUIVerb"="Visual Studio Code" "ExtendedSubCommandsKey"="Directory\\ContextMenus\\VSCode" "Icon"="C:\\Program Files \\Microsoft VS Code\\Code.exe”
; 添加右鍵單擊背景的子菜單 [HKEY_CLASSES_ROOT\\Directory\\Background\\shell\\VSCode] "MUIVerb"="Visual Studio Code" "ExtendedSubCommandsKey"="Directory\\ContextMenus\\VSCode" "Icon"="C:\\ Program Files\\Microsoft VS Code\\Code.exe”
[HKEY_CLASSES_ROOT\\Directory\\ContextMenus\\VSCode]
[HKEY_CLASSES_ROOT\\Directory\\ContextMenus\\VSCode\\shell]
; 設置文本和圖標 [HKEY_CLASSES_ROOT\\Directory\\ContextMenus\\VSCode\\shell\\open] "MUIVerb"="打開文件夾" "Icon"="C:\\Program Files\\Microsoft VS Code\\Code.exe"
[HKEY_CLASSES_ROOT\\Directory\\ContextMenus\\VSCode\\shell\\openwsl] "MUIVerb"="在 WSL 中打開文件夾" "Icon"="C:\\Program Files\\Microsoft VS Code\\Code.exe"
; 設置命令 [HKEY_CLASSES_ROOT\\Directory\\ContextMenus\\VSCode\\shell\\open\\command] @=""C:\\Program Files\\Microsoft VS Code\\Code.exe" "%V""
[HKEY_CLASSES_ROOT\\Directory\\ContextMenus\\VSCode\\shell\\openwsl\\command] @="wsl.exe --cd "%V" 代碼。" ; 這將打開當前文件夾 WSL 端,然后從那里運行代碼
結果: 示例圖像
來自: https : //gist.github.com/mbartelsm/be2a8ea761e5358cd04e3777d107b186#file-vscode_context-reg
這對於“使用 WSL 中的代碼打開”(在 WSL 中打開文件):
制作一個注冊表文件(.reg),粘貼代碼並運行:
Windows 注冊表編輯器 5.00 版
[HKEY_CLASSES_ROOT*\\shell\\VSCodeWsl] @="在 WSL 中使用代碼打開(&ith)" "Icon"="C:\\Program Files\\Microsoft VS Code\\Code.exe"
[HKEY_CLASSES_ROOT*\\shell\\VSCodeWsl\\command] @="wsl.exe 代碼 "$(wslpath '%1')""
結果: 在 wsl 中使用代碼打開示例
結合Open with Code (WSL) for folder和Open with Code (WSL) for file 。
感謝@Mogzol解決彈窗問題。
Windows Registry Editor Version 5.00
; You may replace
; C:\\Program Files\\Microsoft VS Code\\Code.exe
; with
; C:\\Users\\Your User Name\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe
; for correct VS Code icon
; Add the option for right-click on a folder
[HKEY_CLASSES_ROOT\Directory\shell\VSCodeWSL]
@="Open with Code (WSL)"
"Icon"="C:\\Program Files\\Microsoft VS Code\\Code.exe"
[HKEY_CLASSES_ROOT\Directory\shell\VSCodeWSL\command]
@="mshta vbscript:Execute(\"CreateObject(\"\"Wscript.Shell\"\").Run(\"\"wsl.exe code \"\"\"\"$(wslpath '%V')\"\"\"\"\"\", 0, False)(window.close)\")"
; Add the option for right-click in the background of current folder
[HKEY_CLASSES_ROOT\Directory\Background\shell\VSCodeWSL]
@="Open with Code (WSL)"
"Icon"="C:\\Program Files\\Microsoft VS Code\\Code.exe"
[HKEY_CLASSES_ROOT\Directory\Background\shell\VSCodeWSL\command]
@="mshta vbscript:Execute(\"CreateObject(\"\"Wscript.Shell\"\").Run(\"\"wsl.exe code \"\"\"\"$(wslpath '%V')\"\"\"\"\"\", 0, False)(window.close)\")"
; Add the option for right-click on a file
[HKEY_CLASSES_ROOT\*\shell\VSCodeWSL]
@="Open with Code (WSL)"
"Icon"="C:\\Program Files\\Microsoft VS Code\\Code.exe"
[HKEY_CLASSES_ROOT\*\shell\VSCodeWSL\command]
@="mshta vbscript:Execute(\"CreateObject(\"\"Wscript.Shell\"\").Run(\"\"wsl.exe code \"\"\"\"$(wslpath '%1')\"\"\"\"\"\", 0, False)(window. Close)\")"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.