Windows下设置全局以管理员身份运行cmd
原理是修改注册表,下面是注册表文件的内容。
将下面代码保存到文本中,并重命名为cmd.reg。双击,可设置为任意位置打开命令行都是管理员身份
Windows Registry Editor Version 5.00; Created by: Shawn Brink; ; Tutorial: /tutorials/47415-open-command-window-here-administrator.html[-HKEY_CLASSES_ROOT\Directory\shell\runas][HKEY_CLASSES_ROOT\Directory\shell\runas]@="Open cmd here as Admin""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 cmd here as Admin""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 cmd here as Admin""HasLUAShield"=""[HKEY_CLASSES_ROOT\Drive\shell\runas\command]@="cmd.exe /s /k pushd \"%V\""
将下面代码保存到文本中,并重命名为remove.reg。双击可恢复之前的注册表
Windows Registry Editor Version 5.00; Created by: Shawn Brink; ; Tutorial: /tutorials/47415-open-command-window-here-administrator.html[-HKEY_CLASSES_ROOT\Directory\shell\runas][-HKEY_CLASSES_ROOT\Directory\Background\shell\runas][-HKEY_CLASSES_ROOT\Drive\shell\runas]