在我的电脑上试过。使用 Powershell 运行可以,但是当我使用 open with 并选择“C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe”时,它不会运行。
我能够通过修改注册表来解决它。一个快速的谷歌搜索将我带到这个关键
"HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\0\Command"
我复制了价值数据
"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" "-Command" "if((Get-ExecutionPolicy ) -ne 'AllSigned') { Set-ExecutionPolicy -Scope Process Bypass }; & '%1'"
并替换了命令
"HKEY_CURRENT_USER\Software\Classes\Applications\powershell.exe\shell\open\command"
我还没有重新启动,我不知道未来的更新会如何影响这一点。如果您有多个用户也可以应用它,这也是当前用户密钥而不是本地计算机。
请注意,PowerShell 的一项安全功能是用户无法通过双击启动脚本。请注意此命令“Set-ExecutionPolicy -Scope Process Bypass”。如果您修改此设置,请务必小心。
哦,我需要提醒您在进行任何更改之前备份注册表项。