Windows 中按住 Shift + 鼠标右键弹出菜单中可以选择 Powershell 打开当前路径的 Shell 窗口。虽然 Powershell 很强大,但是自己习惯了CMD,所以还是改一下吧。

创建一个 reg 文件,将代码内容放到文件中,然后执行导入注册表就可以了。

非管理员模式

Windows Registry Editor Version 5.00
[-HKEY_CLASSES_ROOT\Directory\Background\shell\OpenCmdHere]
[HKEY_CLASSES_ROOT\Directory\Background\shell\OpenCmdHere]
@="在此处打开命令行窗口"
"Extended"=""
 
[HKEY_CLASSES_ROOT\Directory\Background\shell\OpenCmdHere\command]
 
@="cmd.exe -noexit -command Set-Location -literalPath '%V'"

管理员模式

Windows Registry Editor Version 5.00
 
 
[-HKEY_CLASSES_ROOT\Directory\Background\shell\runas]
 
[HKEY_CLASSES_ROOT\Directory\Background\shell\runas]
@="在此处打开命令行窗口(管理员)"
"Extended"=""
"HasLUAShield"=""
 
[HKEY_CLASSES_ROOT\Directory\Background\shell\runas\command]
@="cmd.exe /s /k pushd \"%V\""
 
 
 
[-HKEY_CLASSES_ROOT\Drive\shell\runas]
 
[HKEY_CLASSES_ROOT\Drive\shell\runas]
@="在此处打开命令行窗口(管理员)"
"Extended"=""
"HasLUAShield"=""
 
[HKEY_CLASSES_ROOT\Drive\shell\runas\command]
@="cmd.exe /s /k pushd \"%V\""
 
 
 
[-HKEY_CLASSES_ROOT\LibraryFolder\background\shell\runas]
 
[HKEY_CLASSES_ROOT\LibraryFolder\background\shell\runas]
"Extended"=""
"HasLUAShield"=""
@="在此处打开命令行窗口(管理员)"
 
[HKEY_CLASSES_ROOT\LibraryFolder\background\shell\runas\command]