在 Windows 10 LTSC 添加带图标的终端子菜单右键项

对于 Windows 11 或部分消费版 Windows 10 用户,安装 Windows Terminal 后在文件夹空白处右键就能看到漂亮的“在终端中打开”子菜单。但对于 Windows 10 LTSC 2021 用户来说,安装 Windows Terminal 后默认也只会添加一个简单的右键入口,没有子菜单。

本文记录了如何通过手动修改注册表,为 LTSC 系统添加一个 带图标的终端子菜单,并支持以下功能:

  • 支持点击文件夹图标 或 文件夹内部空白处弹出菜单
  • 子菜单中包含多个终端类型(默认配置、CMD、PowerShell、Git Bash、Anaconda)
  • 每个菜单项都有图标
  • 支持启动后自动定位到当前路径

🧠 为什么 LTSC 没有子菜单?

Windows 10 LTSC 是面向企业和工控场景的长期支持版本,功能上更保守且精简:

  • 不会自动添加现代上下文菜单项
  • Shell 扩展集成能力较弱
  • 注册表集成需手动完成

因此,我们需要手动构建上下文菜单并配置行为。

🛠️ 实现原理

注册表中控制右键菜单的两个关键位置:

注册表路径 控制位置
HKEY_CURRENT_USER\Software\Classes\Directory\shell 右键点击文件夹图标
HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell 右键点击文件夹内空白处

我们分别向这两个路径写入相同的子菜单结构,实现双重触发。

📦 最终注册表文件(终极版)

将下列内容保存为 terminal_menu.reg 文件,编码建议使用 UTF-16 LE(带 BOM)ANSI,然后双击导入:

点击展开完整注册表内容
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
Windows Registry Editor Version 5.00

; ========== 文件夹图标右键菜单 ==========
[HKEY_CURRENT_USER\Software\Classes\Directory\shell\OpenWTHere]
"MUIVerb"="在终端中打开"
"SubCommands"=""
"Icon"="%USERPROFILE%\\AppData\\Local\\Microsoft\\WindowsApps\\Microsoft.WindowsTerminal_8wekyb3d8bbwe\\terminal.ico"

[HKEY_CURRENT_USER\Software\Classes\Directory\shell\OpenWTHere\shell]

[HKEY_CURRENT_USER\Software\Classes\Directory\shell\OpenWTHere\shell\001Default]
"MUIVerb"="默认配置"
"Icon"="%USERPROFILE%\\AppData\\Local\\Microsoft\\WindowsApps\\Microsoft.WindowsTerminal_8wekyb3d8bbwe\\terminal.ico"

[HKEY_CURRENT_USER\Software\Classes\Directory\shell\OpenWTHere\shell\001Default\command]
@="cmd.exe /c start wt.exe -d \"%1\""

[HKEY_CURRENT_USER\Software\Classes\Directory\shell\OpenWTHere\shell\002CMD]
"MUIVerb"="命令提示符"
"Icon"="%SystemRoot%\\System32\\cmd.exe"

[HKEY_CURRENT_USER\Software\Classes\Directory\shell\OpenWTHere\shell\002CMD\command]
@="cmd.exe /c start wt.exe -p \"命令提示符\" -d \"%1\""

[HKEY_CURRENT_USER\Software\Classes\Directory\shell\OpenWTHere\shell\003PowerShell7]
"MUIVerb"="PowerShell"
"Icon"="C:\\Program Files\\PowerShell\\7\\pwsh.exe"

[HKEY_CURRENT_USER\Software\Classes\Directory\shell\OpenWTHere\shell\003PowerShell7\command]
@="cmd.exe /c start wt.exe -p \"PowerShell\" -d \"%1\""

[HKEY_CURRENT_USER\Software\Classes\Directory\shell\OpenWTHere\shell\004GitBash]
"MUIVerb"="Git Bash"
"Icon"="C:\\Program Files\\Git\\git-bash.exe"

[HKEY_CURRENT_USER\Software\Classes\Directory\shell\OpenWTHere\shell\004GitBash\command]
@="cmd.exe /c start wt.exe -p \"Git Bash\" -d \"%1\""

[HKEY_CURRENT_USER\Software\Classes\Directory\shell\OpenWTHere\shell\005Anaconda]
"MUIVerb"="Anaconda"
"Icon"="D:\\Programs\\miniconda3\\Menu\\anaconda_powershell_prompt.ico"

[HKEY_CURRENT_USER\Software\Classes\Directory\shell\OpenWTHere\shell\005Anaconda\command]
@="cmd.exe /c start wt.exe -p \"Anaconda\" -d \"%1\""

; ========== 文件夹内部空白处右键菜单 ==========
[HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\OpenWTHere]
"MUIVerb"="在终端中打开"
"SubCommands"=""
"Icon"="%USERPROFILE%\\AppData\\Local\\Microsoft\\WindowsApps\\Microsoft.WindowsTerminal_8wekyb3d8bbwe\\terminal.ico"

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

[HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\OpenWTHere\shell\001Default]
"MUIVerb"="默认配置"
"Icon"="%USERPROFILE%\\AppData\\Local\\Microsoft\\WindowsApps\\Microsoft.WindowsTerminal_8wekyb3d8bbwe\\terminal.ico"

[HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\OpenWTHere\shell\001Default\command]
@="cmd.exe /c start wt.exe -d \"%V\""

[HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\OpenWTHere\shell\002CMD]
"MUIVerb"="命令提示符"
"Icon"="%SystemRoot%\\System32\\cmd.exe"

[HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\OpenWTHere\shell\002CMD\command]
@="cmd.exe /c start wt.exe -p \"命令提示符\" -d \"%V\""

[HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\OpenWTHere\shell\003PowerShell7]
"MUIVerb"="PowerShell"
"Icon"="C:\\Program Files\\PowerShell\\7\\pwsh.exe"

[HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\OpenWTHere\shell\003PowerShell7\command]
@="cmd.exe /c start wt.exe -p \"PowerShell\" -d \"%V\""

[HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\OpenWTHere\shell\004GitBash]
"MUIVerb"="Git Bash"
"Icon"="C:\\Program Files\\Git\\git-bash.exe"

[HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\OpenWTHere\shell\004GitBash\command]
@="cmd.exe /c start wt.exe -p \"Git Bash\" -d \"%V\""

[HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\OpenWTHere\shell\005Anaconda]
"MUIVerb"="Anaconda"
"Icon"="D:\\Programs\\miniconda3\\Menu\\anaconda_powershell_prompt.ico"

[HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\OpenWTHere\shell\005Anaconda\command]
@="cmd.exe /c start wt.exe -p \"Anaconda\" -d \"%V\""

🧪 检查点 & 注意事项

  • 确保你已正确设置各终端的 profile 名称(在 settings.json 中),如 "Anaconda"
  • 如果导入 .reg 后未生效,记得重启资源管理器或注销再尝试。
  • "Icon"="wt.exe"可能显示错误的图标,可从GitHub下载图标并修改图标路径,其他配置文件的图标也需要改成对应的路径。
  • 如果有不需要的配置,删除.reg中的对应项即可。

✅ 效果展示

成功导入后,右键点击文件夹或空白处,即可看到带图标的“在终端中打开”子菜单,里面列出你定义的终端配置。

终端菜单

如果你想在子菜单中加入 VS Code、WSL 等其他工具,或者希望实现不同启动参数(例如默认开启 conda 环境),也可以继续扩展!

🔄 一键恢复默认右键菜单(可选)

如果你想撤销前面添加的“在终端中打开”子菜单,只需导入以下 .reg 文件即可将相关注册表项全部删除,恢复系统默认状态。

🧼 恢复注册表文件内容(保存为 remove_terminal_menu.reg

1
2
3
4
5
6
7
Windows Registry Editor Version 5.00

; 删除文件夹图标右键菜单
[-HKEY_CURRENT_USER\Software\Classes\Directory\shell\OpenWTHere]

; 删除文件夹空白处右键菜单
[-HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\OpenWTHere]

✅ 使用方法

  1. 将上述内容复制到记事本中。
  2. 保存为 remove_terminal_menu.reg,编码选择 UTF-16 LE(带 BOM)ANSI
  3. 双击导入,或右键选择“合并”。
  4. 重启资源管理器或注销系统后生效。

这样你就可以随时恢复干净的右键菜单环境,方便测试或重新配置。