Windows 右键菜单添加cmd管理员 vscode编辑等

开局提醒:本文所有都需要保存为.reg文件后导入,如果你直接在注册表编辑器中新建相关项,务必注意字符串中的引号是转义过的,也就是要将\"替换为"\\替换为\

文件右键添加编辑功能

效果:
image

给任意后缀的文件都加了这个菜单项
注册表需导入项:

Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\*\shell\editWith]
@=""
"MUIVerb"="&编辑"
"Subcommands"=""

[HKEY_CLASSES_ROOT\*\shell\editWith\shell]

[HKEY_CLASSES_ROOT\*\shell\editWith\shell\notepad]
@="记事本"
"Icon"="C:\\Windows\\System32\\notepad.exe"

[HKEY_CLASSES_ROOT\*\shell\editWith\shell\notepad\command]
@="\"C:\\Windows\\System32\\notepad.exe\" \"%1\""

[HKEY_CLASSES_ROOT\*\shell\editWith\shell\VS code]
"Icon"="C:\\Program Files\\Microsoft VS Code\\Code.exe"

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

文件夹空白处右键添加此处打开cmd

效果图:
image
注册表:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\cmdShow]
@="@shell32.dll,-8506"

[HKEY_CLASSES_ROOT\Directory\Background\shell\cmdShow\command]
@="cmd.exe /s /k pushd \"%V\""

按下shift显示管理员身份运行cmd

注意,键名必须是runas

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\runas]
@="在此处打开命令窗口(管理员)"
"ShowBasedOnVelocityId"=dword:00639bc8
"Extended"=""

[HKEY_CLASSES_ROOT\Directory\Background\shell\runas\command]
@="cmd.exe /s /k pushd \"%V\""

再添加一个子菜单用管理员打开powershell

迫不得已用子菜单,因为同一级只能有一个runas项,这个runas被cmd用了,只好弄个子菜单凑合凑合。不过我一般也用不到powershell

效果:
image
注册表:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\PowershellAdmin]
@=""
"Subcommands"=""
"MUIVerb"="powershell管理员"
"Extended"=""
"ShowBasedOnVelocityId"=dword:00639bc8

[HKEY_CLASSES_ROOT\Directory\Background\shell\PowershellAdmin\shell]

[HKEY_CLASSES_ROOT\Directory\Background\shell\PowershellAdmin\shell\runas]
@="Powershell(管理员)"

[HKEY_CLASSES_ROOT\Directory\Background\shell\PowershellAdmin\shell\runas\command]
@="powershell.exe -noexit -command Set-Location -literalPath '%V'"

改完后注册表结构:
image

补充:
文件夹空白处右键添加使用VS code打开

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\VSCode]
"Icon"="C:\\Program Files\\Microsoft VS Code\\Code.exe"
@="通过 Code 打开"

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

文件夹图标右键添加VS code打开

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\shell\VSCode]
@=hex(2):1a,90,c7,8f,20,00,43,00,6f,00,64,00,65,00,20,00,53,62,00,5f,00,00
"Icon"=hex(2):43,00,3a,00,5c,00,50,00,72,00,6f,00,67,00,72,00,61,00,6d,00,20,\
  00,46,00,69,00,6c,00,65,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]
@=hex(2):22,00,43,00,3a,00,5c,00,50,00,72,00,6f,00,67,00,72,00,61,00,6d,00,20,\
  00,46,00,69,00,6c,00,65,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,22,00,20,00,22,00,25,00,56,00,\
  22,00,00,00

其实跟上面一样,只是注册表路径的区别,键值的格式弄成了REG_EXPAND_SZ导出就成了utf-16编码了

posted @ 2021-08-15 12:53  王冰冰  阅读(223)  评论(0编辑  收藏  举报