0

The PowerShell behavior on ctrl-c/ctrl-b is like in the success case. Catch not being called but finally will. But as the script was interrupted nothing was successful but the results indicate they where.

In the case where we just kill the process , their are revenants that something went wrong as the code in finally never ran.

So how do you determine in finally if we got here because of a ctrl-c or ctrl-b ? So I can distinguish a true success vs a ctrl-c/ctrl-b.

deetle
  • 197
  • 8
  • 2
    I would just set a flag in `catch` to indicate "real" failure. There might be another way without a flag, I don't know of. – zett42 Dec 12 '21 at 19:38
  • Something like this: https://stackoverflow.com/a/16408863? – Abraham Zinala Dec 12 '21 at 20:08
  • The link is for a console solution. Not all PowerShell envirmetns are console based. On windows this doesn't work on Windows PowerShell ISE. I am sure this doesn't work on non windows system neither. – deetle Dec 13 '21 at 21:53

0 Answers0