![](/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.