我有以下注册表项,它创建一个上下文菜单,以在当前目录中以管理员身份打开 powershell shell:
"%bin%\Elevator" -dir "%V" -elev high pwsh -noexit
电梯是一种实用工具,可以在这里找到。
但是它没有提供提升到SYSTEM的选项。
我知道 nircmd,我用它来运行 Regedit 作为系统,如下所示:
nircmd.exe elevatecmd runassystem regedit.exe
,但我不知道如何使用它来打开Pwsh到当前目录。
有谁知道解决办法吗?
非常感谢任何帮助!
将以下内容保存为 .reg 文件并执行它以创建上下文菜单。 您必须将 Nircmd.exe 放入您的 Windows 目录中。
然后,当您右键单击文件夹时,上下文菜单中将出现“PowerShell 系统提示符”
它适用于我的 Windows 10,我认为 Windows 11 上下文菜单的管理方式不同
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\SOFTWARE\Classes\Folder\Shell\SystemPosh]
@="PowerShell System Prompt"
"icon"="\"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe\""
[HKEY_CURRENT_USER\SOFTWARE\Classes\Folder\Shell\SystemPosh\Command]
@="nircmd.exe elevatecmd runassystem powershell -noexit -command \"&{Set-Location '%1'}\""