[英]Why does powershell fail when run from registry open/command
I'm trying to register a PowerShell script to run when I click on a URL in a Windows app (such as Outlook). 当我单击Windows应用程序(例如Outlook)中的URL时,我试图注册要运行的PowerShell脚本。 (I want to be able to open URLs in different browsers/apps based on different URL patterns).
(我希望能够基于不同的URL模式在不同的浏览器/应用中打开URL)。
I've added 我已经添加
"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -file c:\win\bin\url-handler.ps1 "%1"
to HKEY_CLaSSES_ROOT\\http\\shell\\open\\command
(replacing Google Chrome, my default). 到
HKEY_CLaSSES_ROOT\\http\\shell\\open\\command
(取代Google Chrome,我的默认设置)。
The command works fine when in I run it from a CMD console. 当我从CMD控制台运行该命令时,该命令运行正常。 However, when I click a URL in Outlook, a console window opens, a red error message appears, then the console closes too quickly for me to read it.
但是,当我单击Outlook中的URL时,会打开一个控制台窗口,出现红色错误消息,然后控制台关闭得太快,我无法阅读它。
The only error logs I can find in Event Viewer (for application PowerShell) shows 我在事件查看器(适用于应用程序PowerShell)中可以找到的唯一错误日志显示
Engine state is changed from Available to Stopped.
Details:
NewEngineState=Stopped
PreviousEngineState=Available
SequenceNumber=10
HostName=ConsoleHost
HostVersion=2.0
HostId=7ca63c36-fcc1-4fbe-9488-dfc505a80141
EngineVersion=2.0
RunspaceId=a28185bd-f8da-4648-99aa-86066d199e04
PipelineId=
CommandName=
CommandType=
ScriptName=
CommandPath=
CommandLine=
Setting policy to Unrestricted did not solve this. 将策略设置为“不受限制”并不能解决此问题。
How can I track down what the error might be and how to fix it? 如何跟踪可能的错误以及如何解决?
在命令行中添加-noexit
以防止PowerShell控制台立即关闭。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.