Windows: Add Context Menu to Explorer

 20th August 2020 at 2:19pm

给 Windows 文件浏览器增加 Context Menu。

本质上是修改注册表,可以用各种 Context Menu Editor,也可以执行 .reg 文件。

scoop-extras 仓库有个 VS Code Insider 的例子,vscode-install-context.reg

Windows Registry Editor Version 5.00

; 在文件图标上右键
[HKEY_CLASSES_ROOT\*\shell\Open with Code &Insiders]
"Icon"="C:\\Users\\onlyice\\scoop\\apps\\vscode-insiders\\current\\Code - Insiders.exe"
[HKEY_CLASSES_ROOT\*\shell\Open with Code &Insiders\command]
@="\"C:\\Users\\onlyice\\scoop\\apps\\vscode-insiders\\current\\Code - Insiders.exe\" \"%1\""

; 在某个文件夹图标上右键
[HKEY_CLASSES_ROOT\Directory\shell\Open with Code &Insiders]
"Icon"="C:\\Users\\onlyice\\scoop\\apps\\vscode-insiders\\current\\Code - Insiders.exe"
[HKEY_CLASSES_ROOT\Directory\shell\Open with Code &Insiders\command]
@="\"C:\\Users\\onlyice\\scoop\\apps\\vscode-insiders\\current\\Code - Insiders.exe\" \"%1\""

; 在某个文件夹的背景上右键
[HKEY_CLASSES_ROOT\Directory\Background\shell\Open with Code &Insiders]
"Icon"="C:\\Users\\onlyice\\scoop\\apps\\vscode-insiders\\current\\Code - Insiders.exe"
[HKEY_CLASSES_ROOT\Directory\Background\shell\Open with Code &Insiders\command]
@="\"C:\\Users\\onlyice\\scoop\\apps\\vscode-insiders\\current\\Code - Insiders.exe\" \"%V\""

& 符号表示后面的字母是快捷键。

在某个文件夹的背景上右键,如下图所示:

VSCode 官方的例子更好(人工从注册表反编译成 reg 文件):

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

; 在某个文件夹图标上右键
[HKEY_CLASSES_ROOT\Directory\shell\VS Code]
@="Open w&ith Code"
"Icon"="C:\\Program Files\\Microsoft VS Code\\Code.exe"
[HKEY_CLASSES_ROOT\Directory\shell\VS Code\command]
@="\"C:\\Program Files\\Microsoft VS Code\\Code.exe\" \"%1\""

; 在某个文件夹的背景上右键
[HKEY_CLASSES_ROOT\Directory\Background\shell\VS Code]
@="Open w&ith Code"
"Icon"="C:\\Program Files\\Microsoft VS Code\\Code.exe"
[HKEY_CLASSES_ROOT\Directory\Background\shell\VS Code\command]
@="\"C:\\Program Files\\Microsoft VS Code\\Code.exe\" \"%V\""