Reputation: 5008
I'm trying to register a PowerShell script to run when I click on a URL in a Windows app (such as Outlook). (I want to be able to open URLs in different browsers/apps based on different URL patterns).
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).
The command works fine when in I run it from a CMD console. 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.
The only error logs I can find in Event Viewer (for application PowerShell) shows
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?
Upvotes: 0
Views: 4952
Reputation: 23830
add -noexit
to your command line to prevent that the PowerShell console immediately closes.
Upvotes: 1