Is there a way to terminate a hanging process in Powershell?

I am using Powershell to test a call to a COM object method. Due to poor design / coding / everything, this method of a COM object just hangs when it makes errors. My default instinct is to control + c, but this does not work. Should I kill Powershell in order to kill a call to a COM method labeled COM?

Thanks in advance.

+3
source share
3 answers

Are you calling a method on a COM object that lives in the address space of a PowerShell process? If yes, then yes, you must kill PowerShell to cancel the call.

, AppDomains .

, . , COM- . , , COM , . , . .Abort() , .

+6
+1

You may try:

[System.Runtime.Interopservices.Marshal]::ReleaseComObject($obj)

Or move the process to Stop-Process, adding -Force can also help.

0
source

Source: https://habr.com/ru/post/1711588/


All Articles