鼠标右键打开命令行cmd(管理员身份)

参考:https://blog.csdn.net/bdss58/article/details/54745380

添加到注册表

将下面命令保存为reg文件:

Windows Registry Editor Version 5.00

[-HKEY_CLASSES_ROOT\Directory\shell\runas]

[HKEY_CLASSES_ROOT\Directory\shell\runas]
@="Open command window here as Administrator"
"HasLUAShield"=""

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

[-HKEY_CLASSES_ROOT\Directory\Background\shell\runas]

[HKEY_CLASSES_ROOT\Directory\Background\shell\runas]
@="Open command window here as Administrator"
"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]
@="Open command window here as Administrator"
"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]
"HasLUAShield"=""
@="Open command window here as Administrator"

[HKEY_CLASSES_ROOT\LibraryFolder\background\shell\runas\command]

保存 文件名为 Add_Open_Command_Window_Here_as_Administrator.reg 
然后双击执行就可以了。

卸载

类似上面的,执行下面注册表命令就可以了:

Windows Registry Editor Version 5.00

[-HKEY_CLASSES_ROOT\Directory\shell\runas]

[-HKEY_CLASSES_ROOT\Directory\Background\shell\runas]

[-HKEY_CLASSES_ROOT\Drive\shell\runas]

[-HKEY_CLASSES_ROOT\LibraryFolder\background\shell\runas]
~ 

补充:

1、HasLUAShield   By creating a registry value named HasLUAShield (REG_SZ) on the static verb, you can add the UAC shield icon to the corresponding item in the right-click menu. 参考:https://www.winhelponline.com/blog/add-uac-shield-icon-right-click-context-menu-windows-7/

2、pushd   The Pushd command stores the current directory for use by the popd command, and then changes to the specified directory.  参考:http://www.windowscommandline.com/pushd/

猜你喜欢

转载自www.cnblogs.com/pu369/p/9988327.html