1、 win+r在运行窗口中输入regedit打开注册表。

2、文件夹右键菜单

2.1 找到 HKEY_CLASSES_ROOT\Directory\shell 目录,新建,取名为VSCode

2.2、默认值数据修改为通过VS Code打开

2.3、添加可扩充字符串值(E)命名为Icon,并设置图标

2.4、在VSCode项下新建,取名为command

默认的数据修改为:"C:\Users\Administrator\AppData\Local\Programs\Microsoft VS Code\Code.exe" "%V"

3、文件夹空白处右键菜单

HKEY_CLASSES_ROOT\Directory\Background\shell项中同样操作

4、文件右键菜单

HKEY_CLASSES_ROOT\*\shell项中同样操作,只是command默认值最后改成%1

附:直接用注册表脚本导入

VS Code 默认安装路径为C:\Users\Administrator\AppData\Local\Programs\Microsoft VS Code\Code.exe时的注册表

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\shell\VSCode]
@="通过VS Code打开"
"Icon"=hex(2):43,00,3a,00,5c,00,55,00,73,00,65,00,72,00,73,00,5c,00,41,00,64,\
  00,6d,00,69,00,6e,00,69,00,73,00,74,00,72,00,61,00,74,00,6f,00,72,00,5c,00,\
  41,00,70,00,70,00,44,00,61,00,74,00,61,00,5c,00,4c,00,6f,00,63,00,61,00,6c,\
  00,5c,00,50,00,72,00,6f,00,67,00,72,00,61,00,6d,00,73,00,5c,00,4d,00,69,00,\
  63,00,72,00,6f,00,73,00,6f,00,66,00,74,00,20,00,56,00,53,00,20,00,43,00,6f,\
  00,64,00,65,00,5c,00,43,00,6f,00,64,00,65,00,2e,00,65,00,78,00,65,00,00,00

[HKEY_CLASSES_ROOT\*\shell\VSCode\command]
@="“C:\\Users\\Administrator\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe” “%1”"

[HKEY_CLASSES_ROOT\Directory\shell\VSCode]
@="通过VS Code打开"
"Icon"=hex(2):43,00,3a,00,5c,00,55,00,73,00,65,00,72,00,73,00,5c,00,41,00,64,\
  00,6d,00,69,00,6e,00,69,00,73,00,74,00,72,00,61,00,74,00,6f,00,72,00,5c,00,\
  41,00,70,00,70,00,44,00,61,00,74,00,61,00,5c,00,4c,00,6f,00,63,00,61,00,6c,\
  00,5c,00,50,00,72,00,6f,00,67,00,72,00,61,00,6d,00,73,00,5c,00,4d,00,69,00,\
  63,00,72,00,6f,00,73,00,6f,00,66,00,74,00,20,00,56,00,53,00,20,00,43,00,6f,\
  00,64,00,65,00,5c,00,43,00,6f,00,64,00,65,00,2e,00,65,00,78,00,65,00,00,00

[HKEY_CLASSES_ROOT\Directory\shell\VSCode\command]
@="\"C:\\Users\\Administrator\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe\" \"%V\""

[HKEY_CLASSES_ROOT\Directory\Background\shell\VSCode]
@="通过VS Code打开"
"Icon"=hex(2):43,00,3a,00,5c,00,55,00,73,00,65,00,72,00,73,00,5c,00,41,00,64,\
  00,6d,00,69,00,6e,00,69,00,73,00,74,00,72,00,61,00,74,00,6f,00,72,00,5c,00,\
  41,00,70,00,70,00,44,00,61,00,74,00,61,00,5c,00,4c,00,6f,00,63,00,61,00,6c,\
  00,5c,00,50,00,72,00,6f,00,67,00,72,00,61,00,6d,00,73,00,5c,00,4d,00,69,00,\
  63,00,72,00,6f,00,73,00,6f,00,66,00,74,00,20,00,56,00,53,00,20,00,43,00,6f,\
  00,64,00,65,00,5c,00,43,00,6f,00,64,00,65,00,2e,00,65,00,78,00,65,00,00,00

[HKEY_CLASSES_ROOT\Directory\Background\shell\VSCode\command]
@="\"C:\\Users\\Administrator\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe\" \"%V\""