简体   繁体   English

为什么从注册表打开/命令运行Powershell失败

[英]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.

相关问题 为什么在迭代命令输出时批处理文件FOR会失败? - Why does batch file FOR fail when iterating over command output? 为什么在Windows cmd中运行npm install会失败,但是从git bash或vs终端运行时却可以正常工作? - why does npm install fail when run in windows cmd but works fine when run from git bash or vs terminal? 为什么以管理员身份运行时批处理脚本无法执行? - Why does my batch script fail to execute when run as administrator? PowerShell命令从Batch运行 - PowerShell Command run from Batch 如果BufferedWriter仍然打开,为什么BufferedReader失败? - Why does BufferedReader fail if BufferedWriter is still open? 为什么在查看本地HTML文件时IE8无法window.open()(以及如何修复)? - Why does IE8 fail to window.open() when viewing local HTML files (and how to fix it)? 从Powershell打开管理员命令提示符 - Open Administrator Command Prompt from powershell 为什么此命令无法打印Python命令的正确退出代码? - Why does this command fail to print the correct exit code of a Python command? 如何从 nushell 运行 powershell 命令 - how to run powershell command from nushell 为什么在新控制台中从 PowerShell un 运行的 Perl 脚本,而 Python 脚本没有? - Why does a Perl script that is run from PowerShell un in a new console, but a Python script does not?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM