Ast*_*ant 16 powershell windows-10
我一直在寻找一种方法,通过我想在其中打开提示的文件夹的上下文菜单,直接从 Windows 资源管理器打开提升的 Powershell 提示。
我使用的是 Windows 10,到目前为止我看到的所有示例都有用于旧版本的 Windows。我以前在 Windows 8.1 上使用过这个,但更新到 10 时破坏了它。我什至在 Windows 10 上短暂地使用了它,但更新再次破坏了它(2015 年 12 月)。
有谁知道将此功能添加到 Windows的正确方法?还是注定会被 Windows 的未来更新所覆盖?
Ast*_*ant 25
这是我目前所知道的将此功能添加到 Windows 资源管理器中的上下文菜单的唯一方法:
[在提升的 powershell 提示符下运行此脚本]
$menu = 'Open Windows PowerShell Here as Administrator'
$command = "$PSHOME\powershell.exe -NoExit -NoProfile -Command ""Set-Location '%V'"""
'directory', 'directory\background', 'drive' | ForEach-Object {
New-Item -Path "Registry::HKEY_CLASSES_ROOT\$_\shell" -Name runas\command -Force |
Set-ItemProperty -Name '(default)' -Value $command -PassThru |
Set-ItemProperty -Path {$_.PSParentPath} -Name '(default)' -Value $menu -PassThru |
Set-ItemProperty -Name HasLUAShield -Value ''
}
Run Code Online (Sandbox Code Playgroud)
该脚本取自以下链接:
我 99% 肯定这是我在最新的 Windows 补丁“删除”我的注册表设置之前所做的方式(它还删除了一些其他自定义设置,例如 numlock 启动状态,但这不那么烦人)。
如果有人知道更好的方法;即不会不稳定,然后请告诉我,我会接受该答案。
| 归档时间: |
|
| 查看次数: |
10650 次 |
| 最近记录: |