右键单击文件夹后不会出现 VisualStudio 代码“ Open With Code”

刚刚在 Windows 7机器上安装了 Visual Studio Code 1.1.1。当我右键单击一个文件夹时,“用代码打开”将不会出现。

enter image description here

244949 次浏览

右键单击 Windows 文件夹并用 VisualStudio 代码打开复制

  • 创建包含此内容的文件 VsCodeOpenFolder.reg(如果您没有选择默认安装路径,那么您需要调整此文件中的路径) :

     Windows Registry Editor Version 5.00
    ; Open files
    [HKEY_CLASSES_ROOT\*\shell\Open with VS Code]
    @="Edit with VS Code"
    "Icon"="C:\\Program Files (x86)\\Microsoft VS Code\\Code.exe,0"
    [HKEY_CLASSES_ROOT\*\shell\Open with VS Code\command]
    @="\"C:\\Program Files (x86)\\Microsoft VS Code\\Code.exe\" \"%1\""
    ; This will make it appear when you right click ON a folder
    ; The "Icon" line can be removed if you don't want the icon to appear
    [HKEY_CLASSES_ROOT\Directory\shell\vscode]
    @="Open Folder as VS Code Project"
    "Icon"="\"C:\\Program Files (x86)\\Microsoft VS Code\\Code.exe\",0"
    [HKEY_CLASSES_ROOT\Directory\shell\vscode\command]
    @="\"C:\\Program Files (x86)\\Microsoft VS Code\\Code.exe\" \"%1\""
    ; This will make it appear when you right click INSIDE a folder
    ; The "Icon" line can be removed if you don't want the icon to appear
    [HKEY_CLASSES_ROOT\Directory\Background\shell\vscode]
    @="Open Folder as VS Code Project"
    "Icon"="\"C:\\Program Files (x86)\\Microsoft VS Code\\Code.exe\",0"
    [HKEY_CLASSES_ROOT\Directory\Background\shell\vscode\command]
    @="\"C:\\Program Files (x86)\\Microsoft VS Code\\Code.exe\" \"%V\""
    
  • 双击它以创建注册表项。

  • 如果“用代码打开”没有出现在资源管理器的上下文菜单中,那么您应该重新启动系统。

  • 如果您运行的是64位或内部版本的 VS 代码,请相应地更改路径

注意: 这是针对 32位版本的,对于64位版本,请参阅 Cepharum 的答案。

与前面的答案稍有不同,允许非管理员在其上下文菜单中获取功能:

  • 使用此内容创建文件 vsCodeOpenFolder.reg (如果您没有选择默认的安装路径,那么您需要调整此文件中的路径) :

    Windows Registry Editor Version 5.00
    ; Open files
    [HKEY_CURRENT_USER\Software\Classes\*\shell\Open with VS Code]
    @="Edit with VS Code"
    "Icon"="C:\\Program Files (x86)\\Microsoft VS Code\\Code.exe,0"
    [HKEY_CURRENT_USER\Software\Classes\*\shell\Open with VS Code\command]
    @="\"C:\\Program Files (x86)\\Microsoft VS Code\\Code.exe\" \"%1\""
    ; This will make it appear when you right click ON a folder
    ; The "Icon" line can be removed if you don't want the icon to appear
    [HKEY_CURRENT_USER\Software\Classes\Directory\shell\vscode]
    @="Open Folder as VS Code Project"
    "Icon"="\"C:\\Program Files (x86)\\Microsoft VS Code\\Code.exe\",0"
    [HKEY_CURRENT_USER\Software\Classes\Directory\shell\vscode\command]
    @="\"C:\\Program Files (x86)\\Microsoft VS Code\\Code.exe\" \"%1\""
    ; This will make it appear when you right click INSIDE a folder
    ; The "Icon" line can be removed if you don't want the icon to appear
    [HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\vscode]
    @="Open Folder as VS Code Project"
    "Icon"="\"C:\\Program Files (x86)\\Microsoft VS Code\\Code.exe\",0
    [HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\vscode\command]
    @="\"C:\\Program Files (x86)\\Microsoft VS Code\\Code.exe\" \"%V\""
    
  • Double click it to create the registry entries

  • If the "Open with Code" doesn't appear in the Explorer's context menu then you should restart your system.

Essentially I have replaced HKEY_CLASSES_ROOT with HKEY_CURRENT_USER\Software\Classes

对于 VS 代码,这些设置通常按用户存储。

要为新用户帐户设置: 重新运行安装程序。

安装(或重新安装)时,请选中所有复选框,尤其是:

添加“用代码打开”文件资源管理器到文件上下文菜单
在文件资源管理器目录上下文菜单中添加“用代码打开”操作

install vscode

希望这个能帮上忙。

我想补充的是,许多人想去注册方法,因为他们担心他们可能会失去所有的设置。只需重新下载(如果您还没有下载文件)并重新安装。重新安装时,勾选

Add "Open with Code" action to Windows Explorer file context menu
Add "Open with Code" action to Windows Explorer directory context menu

正如在其他答案中已经说过的。你的设置将保持不变。事实上,当它启动的时候,它会和你的工作目录一起启动,就好像你从来没有卸载过它一样。

以下是伦敦腔韵律绝地提供的文件版本,适合与视觉工作室代码的 64位版本一起使用:

Windows Registry Editor Version 5.00
; Open files
[HKEY_CURRENT_USER\Software\Classes\*\shell\Open with VS Code]
@="Edit with VS Code"
"Icon"="C:\\Program Files\\Microsoft VS Code\\Code.exe,0"
[HKEY_CURRENT_USER\Software\Classes\*\shell\Open with VS Code\command]
@="\"C:\\Program Files\\Microsoft VS Code\\Code.exe\" \"%1\""
; This will make it appear when you right click ON a folder
; The "Icon" line can be removed if you don't want the icon to appear
[HKEY_CURRENT_USER\Software\Classes\Directory\shell\vscode]
@="Open Folder as VS Code Project"
"Icon"="\"C:\\Program Files\\Microsoft VS Code\\Code.exe\",0"
[HKEY_CURRENT_USER\Software\Classes\Directory\shell\vscode\command]
@="\"C:\\Program Files\\Microsoft VS Code\\Code.exe\" \"%1\""
; This will make it appear when you right click INSIDE a folder
; The "Icon" line can be removed if you don't want the icon to appear
[HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\vscode]
@="Open Folder as VS Code Project"
"Icon"="\"C:\\Program Files\\Microsoft VS Code\\Code.exe\",0"
[HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\vscode\command]
@="\"C:\\Program Files\\Microsoft VS Code\\Code.exe\" \"%V\""

当 vs 代码用户具有标准用户角色时,通常会发生此问题。在 VS 代码安装管理提示弹出,这意味着 VS 代码是作为管理用户安装的。如果您勾选框,快捷方式被添加,但只应用于管理员帐户,在安装时输入到管理提示符。

快速解决方案是临时将当前用户(将使用 VS 代码)添加到管理员组,卸载,然后再次安装具有当前用户管理权限的 VS 代码,并在安装后将用户从管理员组中删除。

我有同样的问题与早期版本的 VS 代码64位。即使在我重新安装之后,通过检查上面提到的选项,它也不能工作。

我已经安装了代码 v1.25.0的最新更新,这个问题已经自动修复。

vs code version

请找到64位的 regedit 修复程序 给你

上面的注册表条目都不适用于标准(非管理)用户帐户。

然后我把所有的键插入到 HKEY_LOCAL_MACHINE,然后它工作了!

Windows Registry Editor Version 5.00


; when you right click a file
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\*\shell\VSCode]
@="Open with Code"
"Icon"="C:\\Program Files\\Microsoft VS Code\\Code.exe,0"


[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\*\shell\VSCode\command]
@="\"C:\\Program Files\\Microsoft VS Code\\Code.exe\" \"%1\""


; when you right click a folder
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\VSCode]
@="Open Folder in Code"
"Icon"="C:\\Program Files\\Microsoft VS Code\\Code.exe,0"


[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\VSCode\command]
@="\"C:\\Program Files\\Microsoft VS Code\\Code.exe\" \"%1\""


; when you right click a folder while holding shift
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\Background\shell\VSCode]
@="Open Folder in Code"
"Icon"="C:\\Program Files\\Microsoft VS Code\\Code.exe,0"


[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\Background\shell\VSCode\command]
@="\"C:\\Program Files\\Microsoft VS Code\\Code.exe\" \"%V\""


; when you right click the background, not on a particular file or folder.
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\LibraryFolder\Background\shell\VSCode]
@="Open Folder in Code"
"Icon"="C:\\Program Files\\Microsoft VS Code\\Code.exe,0"


[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\LibraryFolder\Background\shell\VSCode\command]
@="\"C:\\Program Files\\Microsoft VS Code\\Code.exe\" \"%V\""

我的 vscode 安装在这里:

C:\Users\saber\AppData\Local\Programs\Microsoft VS Code\code.exe

应该用你的个人电脑用户名替换 SABER

enter image description here

剧本是这样的:

将此内容保存为 * . reg 文件

然后运行它:

Windows Registry Editor Version 5.00


; Open files
[HKEY_CLASSES_ROOT\*\shell\Open with VS Code]
@="Edit with VS Code"
"Icon"="C:\\Users\\saber\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe,0"
[HKEY_CLASSES_ROOT\*\shell\Open with VS Code\command]
@="\"C:\\Users\\saber\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe\" \"%1\""
; This will make it appear when you right click ON a folder
; The "Icon" line can be removed if you don't want the icon to appear
[HKEY_CLASSES_ROOT\Directory\shell\vscode]
@="Open Folder as VS Code Project"
"Icon"="\"C:\\Users\\saber\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe\",0"
[HKEY_CLASSES_ROOT\Directory\shell\vscode\command]
@="\"C:\\Users\\saber\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe\" \"%1\""
; This will make it appear when you right click INSIDE a folder
; The "Icon" line can be removed if you don't want the icon to appear
[HKEY_CLASSES_ROOT\Directory\Background\shell\vscode]
@="Open Folder as VS Code Project"
"Icon"="\"C:\\Users\\saber\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe\",0"
[HKEY_CLASSES_ROOT\Directory\Background\shell\vscode\command]
@="\"C:\\Users\\saber\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe\" \"%V\""

添加可视化工作室代码以在窗口中右键单击文件夹

\\YOUR_PC_USER_NAME\\代替 \\saber\\

如果您已经安装了 vscode,并希望使用“ open with code”选项。

只要从官方网站下载 vscode..。 这里!

运行选中“ open with code”选项的安装程序。

它将使用“ open with code”选项更新现有的 vscode 安装。

只要再次运行安装程序,选择 open in file explorer选项,就可以全部设置好了。

不要担心已经在 vsCode 中打开的文件,它们都不会被更改

尝试找出微软 VS 代码文件它是一些时间在默认位置,有时它是在 C: 用户 PAPPU KUMAR AppData 本地程序微软 VS 代码。

然后将其添加到 vscode.reg (create one)文件中。

Windows Registry Editor Version 5.00


; Open files
[HKEY_CLASSES_ROOT\*\shell\Open with VS Code]
@="Edit with VS Code"
"Icon"="C:\\Users\\PAPPU KUMAR\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe,0"
[HKEY_CLASSES_ROOT\*\shell\Open with VS Code\command]
@="\"C:\\Users\\PAPPU KUMAR\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe\" \"%1\""
; This will make it appear when you right click ON a folder
; The "Icon" line can be removed if you don't want the icon to appear
[HKEY_CLASSES_ROOT\Directory\shell\vscode]
@="Open Folder as VS Code Project"
"Icon"="\"C:\\Users\\PAPPU KUMAR\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe\",0"
[HKEY_CLASSES_ROOT\Directory\shell\vscode\command]
@="\"C:\\Users\\PAPPU KUMAR\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe\" \"%1\""
; This will make it appear when you right click INSIDE a folder
; The "Icon" line can be removed if you don't want the icon to appear
[HKEY_CLASSES_ROOT\Directory\Background\shell\vscode]
@="Open Folder as VS Code Project"
"Icon"="\"C:\\Users\\PAPPU KUMAR\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe\",0"
[HKEY_CLASSES_ROOT\Directory\Background\shell\vscode\command]
@="\"C:\\Users\\PAPPU KUMAR\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe\" \"%V\""

粘贴下面的代码并用 。注册扩展名保存

Windows Registry Editor Version 5.00 ; Open files


[HKEY_CURRENT_USER\Software\Classes\*\shell\Open with VS Code] @="Edit with VS Code"


"Icon"="C:\Users\hp\AppData\Local\Programs\Microsoft VS Code\Code.exe,0"


[HKEY_CURRENT_USER\Software\Classes\*\shell\Open with VS Code\command]


@="\"C:\Users\hp\AppData\Local\Programs\Microsoft VS Code\Code.exe" \"%1\""
; This will make it appear when you right click ON a folder


; The "Icon" line can be removed if you don't want the icon to appear


[HKEY_CURRENT_USER\Software\Classes\Directory\shell\vscode]
@="Open Folder as VS Code Project"


"Icon"="\"C:\Users\hp\AppData\Local\Programs\Microsoft VS Code\Code.exe",0"


[HKEY_CURRENT_USER\Software\Classes\Directory\shell\vscode\command]


@="\"C:\Users\hp\AppData\Local\Programs\Microsoft VS Code\Code.exe" \"%1\""


; This will make it appear when you right click INSIDE a folder ; The "Icon" line can be removed if you don't want the icon to appear


[HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\vscode]


@="Open Folder as VS Code Project"


"Icon"="\"C:\Users\hp\AppData\Local\Programs\Microsoft VS Code\Code.exe",0


[HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\vscode\command]


@="\"C:\Users\hp\AppData\Local\Programs\Microsoft VS Code\Code.exe" \"%V\""

然后按 Windows键,找到 VisualStudio 代码,然后右键单击并打开文件位置:

open vscode location

右键单击并单击 Properties,然后复制文件路径。

enter image description here

打开 regedit:

reg edit

对于以下每一项,双击图标,然后粘贴从上面复制的文件路径:

[HKEY_CURRENT_USER\Software\Classes\*\shell\Open with VS Code]
[HKEY_CURRENT_USER\Software\Classes\*\shell\Open with VS Code\command]
[HKEY_CURRENT_USER\Software\Classes\Directory\shell\vscode]
[HKEY_CURRENT_USER\Software\Classes\Directory\shell\vscode\command]
[HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\vscode]
[HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\vscode\command]

enter image description here

如果你更喜欢使用键盘而不是鼠标。这个解决方案是为你..。

在文件资源管理器(位置)中键入以下命令。

开一个项目

vscode://file/{full path to project}/


vscode://file/c:/myProject/


vscode:// --opens vscode for current directory

打开文件

vscode://file/{full path to file}


vscode://file/c:/myProject/package.json

打开一个要行和列的文件

vscode://file/{full path to file}:line:column


vscode://file/c:/myProject/package.json:5:10

资料来源: http://code.visalstudio.com/docs/Editor/command-line rel = “ norefrer”> https://code.visualstudio.com/docs/editor/command-line

例如:

enter image description here

只需重新运行安装程序并在安装程序中选择选项,然后让它安装。你不会丢失任何数据。一切都会像以前一样完好无损。它只是添加缺少的设置并更新路径。

在资源管理器中使用代码打开。

为什么你没有得到这个,因为你没有添加到视觉工作室的代码,而你安装,备份您的项目,如果你有, 只需按照以下步骤操作即可:

  1. 卸载 VisualStudio 代码。 控制面板程序和特点: 形象

  2. 重新安装 Visual Studio: 在这里你可以获得/下载: < a href = “ https://code.visalstudio.com/Download”rel = “ nofollow norefrer”> https://code.visualstudio.com/Download

  3. 安装时,停在 选择“其他任务”, 打开选项-2框,可在安装过程中, 完成安装: 形象

  4. 完成了,去浏览器看看,你会在浏览器里找到: 形象

你也可以尝试其他方法, 注册表编辑器-这很复杂-

我使用了64位 VS 代码安装程序

把这些代码复制粘贴到你的电脑记事本上

保存为 vscode.reg

然后打开并合并保存的文件。编码愉快。

Windows Registry Editor Version 5.00
; Open files


[HKEY_CLASSES_ROOT\*\shell\Open with VS Code]
@="Edit with VS Code"
"Icon"="C:\\Program Files\\Microsoft VS Code\\Code.exe,0"


[HKEY_CLASSES_ROOT\*\shell\Open with VS Code\command]
@="\"C:\\Program Files\\Microsoft VS Code\\Code.exe\" \"%1\""




; This will handle right clicking on a folder and open that folder
; as a new project


[HKEY_CLASSES_ROOT\Directory\shell\vscode]
@="Open Folder as VS Code Project"
"Icon"="\"C:\\Program Files\\Microsoft VS Code\\Code.exe\",0"


[HKEY_CLASSES_ROOT\Directory\shell\vscode\command]
@="\"C:\\Program Files\\Microsoft VS Code\\Code.exe\" \"%1\""


; This handles the case of right clicking inside of a folder
; to open that folder as a new project


[HKEY_CLASSES_ROOT\Directory\Background\shell\vscode]
@="Open Folder as VS Code Project"
"Icon"="\"C:\\Program Files\\Microsoft VS Code\\Code.exe\",0"


[HKEY_CLASSES_ROOT\Directory\Background\shell\vscode\command]
@="\"C:\\Program Files\\Microsoft VS Code\\Code.exe\" \"%V\""

在我的例子中,我只是重新运行 vscode 设置并将所有复选框标记为选中状态,它就工作了。enter image description here

打开 VS 代码,进入设置,搜索上下文菜单和检查 enter image description here

VSCode 安装目录默认为 C:\Users\{Username}\AppData\Local\Programs\Microsoft VS Code。 您可以在 < a href = “ https://code.visalstudio.com/docs/setup/windows # _ install”rel = “ nofollow norefrer”> 这里查看

使用此内容创建一个 install.reg 文件并运行它。

Windows Registry Editor Version 5.00
; Open files
[HKEY_CURRENT_USER\Software\Classes\*\shell\Open with VS Code]
@="Edit with VS Code"
"Icon"="C:\\Users\\Administrator\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe,0"
[HKEY_CURRENT_USER\Software\Classes\*\shell\Open with VS Code\command]
@="\"C:\\Users\\Administrator\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe\" \"%1\""
; This will make it appear when you right click ON a folder
; The "Icon" line can be removed if you don't want the icon to appear
[HKEY_CURRENT_USER\Software\Classes\Directory\shell\vscode]
@="Open Folder as VS Code Project"
"Icon"="\"C:\\Users\\Administrator\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe\",0"
[HKEY_CURRENT_USER\Software\Classes\Directory\shell\vscode\command]
@="\"C:\\Users\\Administrator\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe\" \"%1\""
; This will make it appear when you right click INSIDE a folder
; The "Icon" line can be removed if you don't want the icon to appear
[HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\vscode]
@="Open Folder as VS Code Project"
"Icon"="\"C:\\Users\\Administrator\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe\",0"
[HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\vscode\command]
@="\"C:\\Users\\Administrator\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe\" \"%V\""

最快的解决方案是下载 VisualStudio 代码并重新安装。

enter image description here

然后勾选“用代码打开”

一个选项,Open with Code Insiders,正被添加到内部版本1.73,特别是为 Windows 11。参见 1.73版本发行说明:

Windows11上下文菜单

在这个版本中,我们将添加 Open with Code Insiders上下文 返回到“ https://blogs.Windows.com/Windows 开发者/2021/07/19/扩展-the-context-menu-and-share-Dialogue-in-Windows-11/”rel = “ nofollow noReferrer”> Windows 11上下文 菜单 如用户先前已选择使用 当安装内部人员的上下文菜单,项目将显示 在旧风格菜单 Shift + F10现在将被替换为 当更新到最新的内部人员时,更新条目。对于其他人来说,你 将需要重新安装内部人员和选择进入,以启用这个菜单项 由于我们在安装向导中遇到的问题 开发这个菜单项时,我们计划对这个特性进行迭代 与内部人士的几个里程碑,以获得信心之前,我们 可以为所有 Windows11用户推出稳定版本。

Windows 11 context menu: Open with Code Insiders