Windows 在当前目录以管理员身份打开 CMD 和 PowerShell
需求是: 在当前目录右键直接以管理员身份打开 CMD 和 PowerShell 。稳定和常用的.reg注册表脚本方案(效果和系统自带“在此处打开命令窗口”类似,但强制管理员权限)。
✅ 一键添加右键菜单( 管理员 CMD )
把下面内容保存为:add_admin_cmd.reg,然后双击导入即可。
Windows Registry Editor Version 5.00
; 在此处打开 CMD (管理员)
[HKEY_CLASSES_ROOT\Directory\Background\shell\runas]
"ShowBasedOnVelocityId"=dword:00639bc8
@="在此处打开 CMD (管理员)"
"Icon"="C:\\Windows\\System32\\cmd.exe"
[HKEY_CLASSES_ROOT\Directory\Background\shell\runas\command]
@="cmd.exe /s /k pushd \"%V\""
✅ 一键添加右键菜单( 管理员 PowerShell )
把下面内容保存为:add_admin_PowerShell.reg,然后双击导入即可。
Windows Registry Editor Version 5.00
; 在此处打开 PowerShell (管理员)
[HKEY_CLASSES_ROOT\Directory\Background\shell\RunWTAdminHere]
@="在此处打开 PowerShell (管理员)"
"Icon"="C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"
[HKEY_CLASSES_ROOT\Directory\Background\shell\RunWTAdminHere\command]
@="powershell.exe -NoProfile -ExecutionPolicy Bypass -Command \"Start-Process wt.exe -Verb RunAs -ArgumentList '-d','\\\"%V\\\"'\""
📌 使用效果
- 在任意文件夹 右键
- 点击:在此处打开 CMD (管理员) 或 在此处打开 PowerShel (管理员)
- 自动弹出 UAC 提示
- CMD 和 PowerShell 会:
- 以管理员权限启动
- 自动进入当前目录