Is there any way to terminate a hung process in Powershell?
com, powershell
Solution
Are you calling a method on a COM object which lives in the address space of the PowerShell process? If so then yes you must kill PowerShell in order to un-hang the call.
EDIT Matthew asked if AppDomains could be used to fix this problem.
Unfortunately no it cannot. The key here is that the COM object is executing native code. This means that at the point where the COM object hangs, the thread is in native code. There is nothing you can do from managed code to unstick a thread in native code. Even calls to .Abort() won't take effect until the thread returns to managed code.
Problem
I'm using Powershell to test a COM object method call. Due to poor design/coding/everything, this COM object method simply hangs when it errors. My default instinct is to control+c out of it, but this does not work. Do I have to kill Powershell to kill a hung COM method call? Thanks in advance.